Azure 无法从Microsoft Graph API获取邮件
我正在尝试使用Graph API从我的outlook帐户获取邮件。我正在使用已配置应用程序的组织outlook帐户 我成功地从apiAzure 无法从Microsoft Graph API获取邮件,azure,azure-ad-graph-api,Azure,Azure Ad Graph Api,我正在尝试使用Graph API从我的outlook帐户获取邮件。我正在使用已配置应用程序的组织outlook帐户 我成功地从apihttps://login.microsoftonline.com/common/oauth2/v2.0/token但在查询api时,我得到以下错误 { "error": { "code": "BadRequest", "message": "Current authenticated context is not valid
https://login.microsoftonline.com/common/oauth2/v2.0/token
但在查询api时,我得到以下错误
{
"error": {
"code": "BadRequest",
"message": "Current authenticated context is not valid for this request. This occurs when a request is made to an endpoint that requires user sign-in. For example, /me requires a signed-in user. Acquire a token on behalf of a user to make requests to these endpoints. Use the OAuth 2.0 authorization code flow for mobile and native apps and the OAuth 2.0 implicit flow for single-page web apps.",
"innerError": {
"request-id": "807ce785-38b6-4fbb-b670-6419768b08c3",
"date": "2019-06-21T11:59:26"
}
}
}
我使用的API是https://graph.microsoft.com/v1.0/me/messages
我使用的标题是:
X-AnchorMailbox:{{my_email}}
Accept:application/json
Authorization:Bearer {{token}}
我使用的应用程序是用于查询api的postman。正如错误消息所说,您获得的令牌实际上没有在用户上下文中签名。您可能使用OAuth2客户端凭据流来获取令牌,而对于调用/me方法,您需要使用隐式授权流,它将用户重定向到login.microsoftonline.com以登录,然后使用获得的(通过委派权限)令牌来调用图 所以你基本上有两个选择: