【发布时间】:2018-12-07 23:23:14
【问题描述】:
我在用 Google 授权码交换访问和刷新令牌时遇到问题。
使用 nodejs googleapis 客户端库,我能够生成身份验证 URL,并通过调用 URL 成功获取身份验证代码。当我尝试在我的服务器上交换此验证码时,问题就出现了。
我正在使用以下参数对“https://www.googleapis.com/oauth2/v3/token”进行 POST 调用:
tokenData = {
code: [code from client],
client_id: [client ID used to get the auth code client-side],
client_secret: [client secret associated with the ClientID],
grant_type: 'authorization_code',
redirect_uri: 'postmessage'
};
拨打此电话后,我会收到以下信息:
{error=unauthorized_client, error_description=Unauthorized}
我已经三重检查了客户端用于获取身份验证代码的 ClientID 是否与服务器上的匹配,并且客户端的 url 已添加到 Google 控制台上的授权 javascript 源中。
我进行了广泛的谷歌搜索以尝试找到解决方案,但似乎很少有关于什么符合“未授权客户端”错误的文档。任何帮助深表感谢。
【问题讨论】:
标签: oauth-2.0 google-authentication