gpt4 book ai didi

node.js - Facebook accountkit 在从 NodeJS 服务器交换 token 时出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 03:24:32 25 4
gpt4 key购买 nike

我一直在将 fb AccounKit 与我的 ionic 应用程序(NodeJS 服务器)集成。前端部分已经完成,我能够发送和接收 OTP 和成功状态。

但是,在从授权代码获取客户端 token 时,我不断收到“Error verifying the token in the\'access_token\'”'错误。我遵循了官方文档中提到的相同过程。

这是我的代码:

var me_endpoint_base_url = 'https://graph.accountkit.com/v1.0/me';
token_exchange_base_url='https://graph.accountkit.com/v1.0/access_token';

var params = {
grant_type: 'authorization_code',
code: request.body.code,
access_token: app_access_token
};
}

// exchange tokens
console.log(Querystring.stringify(params))
var token_exchange_url = token_exchange_base_url + '?' + Querystring.stringify(params);
Request.get({url: token_exchange_url, json: true}, function(err, resp, respBody) {
console.log(respBody);
var view = {
user_access_token: respBody.access_token,
expires_at: respBody.expires_at,
user_id: respBody.id,
};
var me_endpoint_url = me_endpoint_base_url + '?access_token=' + respBody.access_token;
Request.get({url: me_endpoint_url, json:true }, function(err, resp, respBody) {
console.log(respBody);
if (respBody.phone) {
view.method = "SMS"
view.identity = respBody.phone;
} else if (respBody.email) {
view.method = "Email"
view.identity = respBody.email.address;
}
});
});

请帮忙?

最佳答案

在进行服务器到服务器调用以将代码交换为 token 时,您需要在发送的访问 token 中提供您的 Account Kit 应用程序 key 。因此访问 token 应如下所示:

'AA|{app_id}|{app_secret}'

例如。

var app_access_token = ['AA', app_id, app_secret].join('|');

您可以从帐户工具包仪表板中找到您的应用程序 key 。转到developers.facebook.com 上应用程序产品部分下的“帐户工具包”页面,然后单击“帐户工具包应用程序 key ”框旁边的“显示”按钮以查看您的应用程序 key 。

另请记住,您不应该永远在客户端运行的任何 JavaScript 代码中包含您的应用程序 key 。此 secret 只能在您的服务器端 Node.js 代码中使用,其他人不应该能够看到它

关于node.js - Facebook accountkit 在从 NodeJS 服务器交换 token 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46198237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com