我正在使用GTMOAuth-2库来实现到Asana API的OAuth 2授权代码授予流,但是总是得到一个服务器错误500。GTMHTTPFetcher日志如下(选择性编辑):
fetch tokens for app.asana.com
2013-05-08 16:46:58 +0000
Request: POST https://app.asana.com/-/oauth_authorize
Request headers:
Content-Type: application/x-www-form-urlencoded
User-Agent: gtm-oauth2 <user-agent>
Request body: (199 bytes)
client_id=<client-id>&client_secret=_snip_&code=<client-secret>&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fwww.google.com%2FOAuthCallback
Response: status 500
Response headers:
Cache-Control: no-store
Content-Length: 303
Content-Type: text/html; charset=UTF-8
Date: Wed, 08 May 2013 16:46:56 GMT
Pragma: no-cache
Server: nginx
Set-Cookie: <cookie>
X-Asana-Content-String-Length: 303
X-Asana-Preferred-Release-Revision: 20130508_073846_310cafc985fd5fb43121784b58d5dcd2503ffffe
Response body: (303 bytes)
<html>
<head>
<title>Error</title><script>__FILE__="(none)";var config = {
"CLUSTER": "prod",
"PRETTY_JS_CODEGEN": false,
"ENABLED_FEATURES": ""
};</script><link rel="shortcut icon" href="/-/static/luna/browser/images/favicon.ico" />
</head>
<body>
<h3>Error</h3><pre>Server Error</pre>
</body>
</html>我已经仔细检查了身份验证和令牌URL、客户端ID和密钥,确保了Asana和in-app上的重定向URI匹配。有趣的是,授权流程似乎只对应用程序进行了授权( Asana站点将应用程序记录为已授权),但随后似乎从未返回授权令牌。有没有什么地方我可能出错了,或者这真的是一个内部服务器错误?
发布于 2013-05-09 04:52:00
(我在Asana工作)。我不确定这个请求是在流中的什么地方发出的,但它看起来不正确。一旦您获得了授权码(通过让用户与Asana表单进行交互),库就应该向我们的/-/oauth_token端点发出请求,并将代码传递给我们。因此,您可能只需要使用/-/oauth_token端点,而不是您正在做的/-/oauth_authorize端点。
如果您查看我们的OAuth examples,您会注意到有两个不同的URL,一个用于授权,另一个用于令牌交换。
Asana可能会返回500,因为它没有预料到这一点,而我们在发现问题方面做得不够好。
https://stackoverflow.com/questions/16446440
复制相似问题