Azure active directory AADSTS70002:验证凭据时出错。AADSTS50126:无效的用户名或密码

Azure active directory AADSTS70002:验证凭据时出错。AADSTS50126:无效的用户名或密码,azure-active-directory,microsoft-graph-api,access-token,Azure Active Directory,Microsoft Graph Api,Access Token,无法获取访问令牌,授予类型:密码 网址: 有人能找出哪里出了问题吗。 用户名和密码正确。建议您尝试以下方法: 网址: 请求机构: client_id=<client_id>& scope=https://graph.microsot.com/Mail.Read openid User.Read& grant_type=password& username=<email_id>& client_secret=<client_secret

无法获取访问令牌,授予类型:密码

网址:

有人能找出哪里出了问题吗。
用户名和密码正确。

建议您尝试以下方法:

网址:

请求机构:

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>
client\u id=&
范围=https://graph.microsot.com/Mail.Read openid用户。读取&
授权类型=密码&
用户名=&
客户机密=&
密码=
答复如下:
对我来说,以下内容是在《邮递员》中完成的

网址(张贴):

请求正文(正文):

client\u id=&
范围=https://graph.microsoft.com/.default&
授予\类型=客户端\凭据&
客户机密=

可能是编码问题。正文需要进行URL编码。通常,如果你使用框架提供的工具来构建身体,它会为你这样做。@Gaurav Modi,我已经更新了新的答案。如果有什么不清楚的地方,请让我知道,谢谢。那不是graph.microsoFt.com吗?这里你使用的是grant\u type=client\u凭据,它肯定会给你grant\u type错误=password@shobhit-walia,我没有说它对grant_type=password有效。我只是给出了一个获取访问令牌的解决方案,这对我来说是有效的,我提出了这项决议。你能投反对票吗?嗨@Arpita,是的,你是对的,你的解决方案会起作用,但在上面的场景中不会,因为在这里,给定的问题中明确提到了grant_type=password。
  {'grant_type': 'password', 'client_id': <client_id>, 'scope': 'openid User.Read Mail.Read', 'username': '<email_id>', 'client_secret': '<client_secret>, 'password':<password>}
    {'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'}
Post https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
application/x-www-form-urlencoded
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>
https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
Content-Type 
application/x-www-form-urlencoded
client_id=<client_id>&
scope=https://graph.microsoft.com/.default&
grant_type=client_credentials&
client_secret=<client_secret>