【问题标题】:coinbase oauth2 sometimes failed to renew access token (using refresh token)coinbase oauth2 有时无法更新访问令牌(使用刷新令牌)
【发布时间】:2014-02-26 02:33:03
【问题描述】:

我正在将 coinbase 集成到 iOS 应用程序中,并且正在使用 Oauth2 进行身份验证。通过通常的工作流程后,我能够获得访问令牌。每当任何请求达到 401(到期时)时,我还通过调用以下命令尝试刷新我的访问令牌:

发布https://coinbase.com/oauth/token 数据:

grant_type=refresh_token&refresh_token=abcd1234&client_id=theclientid&client_secret=somesecretid

它可以工作一段时间,但有时会因请求响应而失败:

NSHTTPURLResponse: 0x15eb2730
{ URL: https://coinbase.com/oauth/token } { status code: 401, headers {
"CF-RAY" = "f67d477aae4052e-YYZ";
"Cache-Control" = "no-store";
Connection = "keep-alive";
"Content-Type" = "application/json; charset=utf-8";
Date = "Sun, 02 Feb 2014 15:14:14 GMT";
Pragma = "no-cache";
Server = "cloudflare-nginx";
"Set-Cookie" = "__cfduid=<some long alpha-numeric string>; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly";
Status = "401 Unauthorized";
"Strict-Transport-Security" = "max-age=31536000";
"Transfer-Encoding" = Identity;
Vary = "Accept-Encoding";
"Www-Authenticate" = "Bearer realm=\"Doorkeeper\", error=\"invalid_request\", error_description=\"The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.\"";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = "<some long alpha-numeric string>";
"X-Runtime" = "0.012066";
"X-Ua-Compatible" = "IE=Edge,chrome=1";
} }

以前有人遇到过这个错误吗?我假设请求 URL 总是正确的。我不确定为什么它会抱怨“缺少必需的参数”或“不支持的参数”。我还没有弄清楚失败的模式。希望那里的人可能以前见过这个。

【问题讨论】:

    标签: authentication ios7 oauth-2.0


    【解决方案1】:

    我无法直接找到有关 refresh_token 请求的任何文档,但我认为您应该在 refresh_token 请求中也包含 redirect_uri(基于此:https://coinbase.com/docs/api/authentication#collapse2)。

    另外,我注意到几天前我的官方 coinbase 应用程序需要重新授权,但是当我登录我的 coinbase 帐户时,它说该应用程序是 25 天前授权的。那么,也许甚至 request_tokens 也有超时?您的 request_token 请求是否在一段时间未使用该应用后失败?

    或者,也许 coinbase 重置了某些东西并使其所有 access_tokens 和 refresh_tokens 无效,因为我的应用程序以前在 refresh_tokens 方面工作正常,但现在在 refresh_token 请求上失败了。

    所以,我建议在发生这种情况时让您的应用重新授权,并获取新的 access_token 和 refresh_token,因为我认为这是官方 coinbase 应用所做的。

    【讨论】:

      猜你喜欢
      • 2021-12-17
      • 2017-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2019-06-29
      • 2017-02-07
      • 2014-09-13
      相关资源
      最近更新 更多