Forum Discussion
OutlookOffice365:how to get access token(API) using username and App password when MFA is enabled?
As you all aware that MS Office 365 changed from Basic Auth to Modern Authentication recently, so it blocks all access from protocols such as IMAP/POP/SMTP. In that case we have to use Access token (OAUTH 2.0) generated from MS API by passing the client/secret, username , password & scope.
Currently, I'm able to get the access token for users who do not use MFA(able to access user mailboxes with IMAP protocol), but for the users who uses MFA, we have the app password for them. For mfa users, I'm passing their app password(in the password field) to get the access token, but I'm getting the following error
"error": "invalid_grant",
"error_description": "AADSTS50126: Error validating credentials due to invalid username or password.",
"error_codes": [
50126
],
grant type I'm using for this request is "password". Any suggestion how to resolve this issue? Do I delegate any API permissions in azure ad application side? I have currently enabled the permission IMAP.AccessforALL for my usage.
Please help.. Thanks in advance