我正在尝试将Office 365 apis与我的应用程序集成 . 我可以使用OAuth2进程生成访问令牌 . 但是使用生成的访问令牌调用api会给我们401错误 .
这是我得到的令牌的回应
{
"token_type": "Bearer",
"scope": "ActivityReports.Read ThreatIntelligence.Read",
"expires_in": "3599",
"ext_expires_in": "0",
"expires_on": "1480350031",
"not_before": "1480346131",
"resource": "https://manage.office.com",
"access_token": "===access token===",
"refresh_token": "===refresh token===",
"id_token": ""
}
我试图用 Headers 作为授权:承载调用 endpoints “https://outlook.office.com/api/v2.0/me”,但给我401错误 .
有什么想法吗 ?
谢谢,
1 回答
我相信这里的问题是您已经获得了与您尝试查询的API不同的 endpoints 的访问令牌 . 如果您注意到,当您需要具有资源“outlook.office.com”的令牌以查询outlook API时,令牌中的“资源”为“manage.office.com” .
您是否可以检查代码中是否指定了满足您需求的正确资源,另外,请确保为访问该API所需的权限正确配置了客户端应用程序 .
我希望这有帮助!