我试图添加亚马逊登录下面的“授权CodeGrant”我得到的代码客户端,并将其发送到我的节点js express服务器,但无法从亚马逊获得访问令牌。我收到500内部存储错误,并且:
x-amzn-errortype': 'InternalFailure:http://internal.amazon.com/coral/com.amazon.coral.service/'我的代码:
async function getAmazonAccessTokenFromCode(code) {
try {
const { data } = await axios({
url: 'https://api.amazon.com/auth/o2/token',
method: 'POST',
headers: {
"Content-type": "application/x-www-form-urlencoded"
},
params: {
grant_type: "authorization_code",
code,
client_id: "my_client_id",
client_secret: "my_client_secret",
redirect_uri: 'http://localhost:3000/amazon-auth',
}
})
console.log("data", data)
return data.access_token
} catch (err) {
console.log("err", err)
return null
}
}发布于 2020-04-25 19:26:54
我将axios fetch请求中的"params“替换为"data”,从而使其正常工作。
发布于 2021-06-14 15:54:58
此外,如果不起作用,请尝试在内容类型中使用application/json。这对我很管用。
https://stackoverflow.com/questions/61293436
复制相似问题