0
我想在我的應用程序中具有允許用戶授權Bitbucket的功能。我跟着https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html。使用Node.js的Bitbucket OAuth2
下工作,並帶來如預期到位桶授權屏幕: https://bitbucket.org/site/oauth2/authorize?client_id=了{client_id} & RESPONSE_TYPE =代碼
然而,這部分發出有關無效格蘭特錯誤。
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=authorization_code -d code={code}
我正在使用的Node.js request
模塊以及使用該代碼如下:
request.post(
'https://bitbucket.org/site/oauth2/access_token',
{
json: {
client_id: config.get('app.bitbucket_client_id'),
client_secret: config.get('app.bitbucket_client_secret'),
code: req.query.code,
grant_type: "authorization_code"
}
}, function (error, response, body) {
// Do something here
}
}
{ 「結果」:{ 「ERROR_DESCRIPTION」: 「不支持的授權類型:無」,「錯誤「:」invalid_grant「}}
請指教!
是不是錯誤說你沒有在請求JSON中包含grant_type參數? –
它應該是什麼? 如果我添加grant_type:「authorization_code」,它會投訴... {「result」:{「error_description」:「Unsupported grant type:None」,「error」:「invalid_grant」}} –
@RickLee我試圖添加grant_type,但問題依然存在。 –