【问题标题】:Can't get access token from amazon无法从亚马逊获取访问令牌
【发布时间】:2020-04-18 17:33:25
【问题描述】:

我正在尝试在“授权 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
    }
}

【问题讨论】:

    标签: node.js server fetch amazon access-token


    【解决方案1】:

    我通过在 axios 获取请求中将“params”替换为“data”来使其工作。

    【讨论】:

      【解决方案2】:

      此外,如果它不起作用,请尝试在内容类型中使用 application/json。它对我有用。

      【讨论】:

        猜你喜欢
        • 2019-06-21
        • 1970-01-01
        • 2014-09-04
        • 1970-01-01
        • 1970-01-01
        • 2013-11-25
        • 2020-05-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多