1

l 尝试通过以下方式获取访问令牌使用javascript fetch:

fetch('https://api.dropboxapi.com/oauth2/token', {
method: 'POST',
code: AUTHORIZATION_CODE,
grant_type: 'authorization_code',
redirect_uri: `${REDIRECT_URI}${window.location.pathname}`,
headers: {
'Content-Type': "application/x-www-form-urlencoded"
},
CLIENT_ID: CLIENT_SECRET
})
.then(res => res.json())
.then(data => console.log('access data =>', data))
.catch(err => console.log('access err =>',err));

从“https://www.dropbox.com/oauth2/authorize...”域成功重定向后,我收到了 AUTHORIZATION_CODE。

但我有一个错误

{"error_description": "No auth function available for given request", "error": "invalid_request"}

我究竟做错了什么?因为我从这里遵循 curl 请求示例: https ://www.dropbox.com/developers/documentation/http/documentation#oauth2-token

curl https://api.dropbox.com/oauth2/token \
    -d code=<AUTHORIZATION_CODE> \
    -d grant_type=authorization_code \
    -d redirect_uri=<REDIRECT_URI> \
    -u <APP_KEY>:<APP_SECRET>

谢谢!

4

0 回答 0