'AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password

Unable to Get the Access token , Grant Type: password

URL :

https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token?resources=https%3A%2F%2Fgraph.microsoft.com%2F

Request:

  {'grant_type': 'password', 'client_id': <client_id>, 'scope': 'openid User.Read Mail.Read', 'username': '<email_id>', 'client_secret': '<client_secret>, 'password':<password>}

Response:

    {'correlation_id': 'bbe33e96-aeb8-4e8f-8a2f-1330510c298f', 
     'error_codes': [70002, 50126],
     'timestamp': '2018-12-19 06:58:03Z',
     'error': 'invalid_grant',
     'trace_id': 'c69686fb-a84e-4299-a72c-0cf079381300', 
     'error_description': 'AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: c69686fb-a84e-4299-a72c-0cf079381300\r\nCorrelation ID: bbe33e96-aeb8-4e8f-8a2f-1330510c298f\r\nTimestamp: 2018-12-19 06:58:03Z'}

Can any one find out whats going wrong. User name and password are correct.



Solution 1:[1]

Suggest you try the following way:

URL:

Post https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token

Content-Type:

application/x-www-form-urlencoded

Request body:

client_id=<client_id>&
scope=https://graph.microsot.com/Mail.Read openid User.Read&
grant_type=password&
username=<email_id>&
client_secret=<client_secret>&
password=<password>

And the response: enter image description here

Solution 2:[2]

For me the below worked out in Postman.

URL(POST) :

https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token

Header:

Content-Type 
application/x-www-form-urlencoded

Request Body(text):

client_id=<client_id>&
scope=https://graph.microsoft.com/.default&
grant_type=client_credentials&
client_secret=<client_secret>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 4b0