我正在尝试实现“使用 Outlook.com 登录”流程,其中涉及客户端和服务器代码。
流程是:
https://login.live.com/oauth20_authorize.srf?client_id=< client_id >&response_type=code&redirect_uri=< the login html page >&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fcontacts.read+onedrive.readwrite
https://login.live.com/oauth20_token.srf
正文中的下一个参数:client_id、redirect_uri、client_secret、grant_type="authorization_code"和 code=< 上一步的代码 >。
我收到了 access_token 和 refresh_tokem,它们的有效期应该是 1 小时。
https://apis.live.net/v5.0/me?access_token= <我刚刚得到的访问 token >
并得到错误 401:
{
"error": {
"code": "request_token_invalid",
"message": "The access token isn't valid."
}
}
这个流量可以吗?
最佳答案
我终于能够让这个工作。
首先,获取用户信息的正确端点是:
https://graph.microsoft.com/v1.0/me
其次,步骤1中的范围不应该设置为openid ...
而是 User.Read
.
关于live-sdk - Microsoft Live API - 访问 token 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39305655/