错误:{"invalid_client"} 在 Nodejs 中使用 Apple 登录

我正面临这个错误 |错误:'{"error":"invalid_client"}'|使用 nodejs 使用 Apple API 调用 signIn 时。我已经尝试了很多次,但我遇到了同样的错误。我尝试了不同的代码、不同的生成 ClientID 和 PrivateKeys,但得到了相同的错误。我还阅读了 gitHub 和 developer.apple.com 上的问题,但没有一个答案对我有帮助。任何人的任何帮助将不胜感激。 以下是我正在处理的代码!

const getclientSecret = () => {
const headers = {
    alg: 'ES256',kid: KEY_ID
};
const timeNow = Math.floor(Date.now() / 1000);
const claims = {
    iss: TEARM_ID,aud: 'https://appleid.apple.com',sub: CLIENT_ID,iat: timeNow,exp: timeNow + 15777000
};

const token = jwt.sign(claims,PRIVATEKEY,{
    algorithm: 'ES256',header: headers
    // expiresIn: '24h'
});

return token;

}

const clientSecret = getclientSecret();

const params = {
    grant_type: 'authorization_code',// refresh_token authorization_code
    code: req.body.code,//apple Login Token
    //redirect_uri: [REDIRECT_URI],client_id: CLIENT_ID,client_secret: clientSecret
    // refresh_token:body.id_token
};

try {

    axios.request({
        method: 'POST',url: 'https://appleid.apple.com/auth/token',data: querystring.stringify(params),headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }).then(response => {
        console.log('response',response);
    }).catch(error => {
        console.log('error1',error.response.data);
        res.send({
            success: false,error: error.response.data
        })
    })

} catch (error) {
    console.log('error',error);
}

回复

 statusCode: 400,error: '{"error":"invalid_client"}'
iCMS 回答:错误:{"invalid_client"} 在 Nodejs 中使用 Apple 登录

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/156990.html

大家都在问