OAuth 2之后如何使用Basecamp3 API获取令牌?

时间:2019-03-27 20:12:05

标签: javascript api oauth-2.0 basecamp

我正在使用Basecamp3 API和认证OAuth2来构建Javascript应用程序。我首先在https://launchpad.37signals.com/integrations注册了我的应用,以便提供redirect_uriclient_idclient_secret来配置OAuth 2库。

启动应用程序后,一切似乎都可以正常运行。我可以登录Basecamp,并可以访问我的Basecamp 3数据。

Basecamp3_autorization

但是,配置完成后,窗口关闭,我无权访问我的应用程序。

我检查了日志,发现错误400:

error: 2019-03-27 02:59:55.5955 Error when requesting api key StatusCodeError: 400 - {"timestamp":1553716795279,"status":400,"error":"Bad Request","message":"Bad request","path":"/thirdparty/proxy/oauth2/requestTokens/"}

我似乎无法获得令牌,因此我像将第一个授权链接(解释为here)一样,将实际链接https://launchpad.37signals.com/authorization/token更改为https://launchpad.37signals.com/authorization/token?type=web_server

但是我仍然收到错误,但错误500:

error: 2019-03-27 02:56:16.5616 Error when requesting api key StatusCodeError: 500 - {"apierror":{"status":"INTERNAL_SERVER_ERROR","timestamp":"27-03-2019 07:56:16","message":"Unexpected error","debugMessage":"could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement","errors":null}}

我什至尝试将协议https更改为http。我仍然收到错误500:

error: 2019-03-27 03:05:15.515 Error when requesting api key StatusCodeError: 500 - {"timestamp":1553717115170,"status":500,"error":"Internal Server Error","message":"Error requesting from http://launchpad.37signals.com/authorization/token?client_id=1111111111111111111111111&client_secret=22222222222222222222222&code=abcdef&redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fredirect&grant_type=authorization_code; got HTTP response HTTP/1.1 307 Temporary Redirect","path":"/thirdparty/proxy/oauth2/requestTokens/"}

我尝试了多种更改请求的方法,但这没有用。

我试图通过Postman获得令牌(以与我的应用相同的方式),但我不能。

您知道此错误来自何处吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。问题来自我如何在命令行中使用curl来创建POST请求。我将元素放在url中,而不是使用--data选项。