Microsoft Live API-访问令牌无效

bur*_*rgi 9 windows-live windows-live-id live-sdk

我正在尝试实现“使用Outlook.com登录”流程,该流程涉及客户端和服务器代码。流程是:

  1. 从客户端将用户重定向到:

https://login.live.com/oauth20_authorize.srf?client_id= <client_id>&response_type = code&redirect_uri = <登录html页面>&scope = openid + offline_access + profile + https:%2f%2foutlook.office.com%2fmail。发送+ https:%2f%2foutlook.office.com%2fcontacts.read + onedrive.readwrite

  1. 我将代码返回到html页面,并将其发布到我的java服务器。

  2. 在服务器端,我使用代码来获取访问和刷新令牌,并通过POST请求访问:https : //login.live.com/oauth20_token.srf

正文中的下一个参数:client_id,redirect_uri,client_secret,grant_type =“ authorization_code”和code = <上一步中的代码>。

我收到了access_token和refresh_tokem,它们应该有效1小时。

  1. 仍然在服务器上,我称URL

https://apis.live.net/v5.0/me?access_token= <我刚刚获得的访问令牌>

并得到错误401:

{
   "error": {
      "code": "request_token_invalid", 
      "message": "The access token isn't valid."
   }
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

Nat*_*man 0

我终于能够让这个工作了。

首先,获取用户信息的正确端点是: https:
//graph.microsoft.com/v1.0/me

其次,步骤 1 中的范围不应设置为openid ...,而应设置为User.Read