microsoft_graph oAuth 刷新错误

microsoft_graph oAuth refresh error

我允许用户使用 oAuth 和 Microsoft Graph 授权他们的 Microsoft 帐户 API。我正在使用 this omniauth strategy to facilitate the authorization. In the OmniAuth strategy, it includes the resource for both authorize_params and token_params "https://graph.microsoft.com”。这让我可以很好地进行身份验证,但是当我去刷新身份验证时,我得到了返回的错误:

{"error"=>"unauthorized_client", "error_description"=>"AADSTS70001: Resource 'https://graph.microsoft.com/' is not supported as resource.\r\n"}

连同 trace_id 和其他一些东西,如果需要,我会 post。

我要刷新的端点是 POST https://login.microsoftonline.com/common/oauth2/v2.0/token,带有 client_idrefresh_tokengrant_type: "refresh_token" 参数。

就在上周,刷新此 oAuth 令牌工作正常。 Microsoft Graph API 有什么变化吗?

事实证明,这就像我对 v1.0 进行授权一样简单,但试图重新对 v2.0 进行授权。不知道为什么这会一直有效,但确保他们使用相同版本的 API 已经解决了这个问题。

您可能想看看 Refreshing a Token

听起来你只说了一部分,你只是缺少一些额外的参数:

  • grant_type - 设置为 refresh_token
  • refresh_token - 您从提供商那里收到的刷新令牌值
  • client_id - 这是上面的应用程序 ID
  • client_secret - 这是我们之前生成的密码
  • scope - 这应该与您第一次请求的同一组范围相匹配
  • redirect_uri - 这是在您的应用程序注册中定义的重定向 URI

这些格式在你application/x-www-form-urlencodedPOST到https://login.microsoftonline.com/common/oauth2/v2.0/token

POST URL: https://login.microsoftonline.com/common/oauth2/v2.0/token
POST HEADER: Content-Type: application/x-www-form-urlencoded
POST BODY: grant_type=refresh_token&refresh_token=[REFRESH TOKEN]
           &client_id=[APPLICATION ID]&client_secret=[PASSWORD]
           &scope=[SCOPE]&redirect_uri=[REDIRECT URI]