即使客户端 ID 正确,客户端 - google-auth-library 也无效

问题描述 投票:0回答:1

我在nodejs中使用

google-auth-library

一切都运转良好。直到由于某种原因我的一个域名关闭了。

api.example1.com

在谷歌控制台中,重定向 uri 是 ->

https://api.example1.com/google/cb
这条路线没有什么特别的,因为我已经得到了

auth_code
来自客户端,例如 -> React、Android


import { useGoogleLogin } from "@react-oauth/google";

所以我刚刚在

api.example2.com
上创建了另一个具有相同代码的服务器,并且我还在授权的重定向网址中添加了它。

但不幸的是。即使它给出错误

CLIENT_ID
CLIENT_SECRET
正确。

这是我遇到的错误

{
"error": "invalid_client",
"error_description": "Unauthorized"
}
const oAuth2Client = new OAuth2Client({
  clientId: process.env.GOOGLE_CLIENT_ID,
  clientSecret: process.env.GOOGLE_SECRET_ID,
  redirectUri: process.env.REDIRECT_URI,
});

使用方法

const { tokens } = await oAuth2Client.getToken(code);
node.js oauth-2.0 google-oauth google-auth-library
1个回答
0
投票

过度自信并不是一件好事。

您可能认为每个凭证都是有效的,但事实并非如此。

就我而言,我的

CLIENT_SECRET
是不同的。

因此,如果可能,请仔细检查每个凭据是否存在此错误。

invalid_client

 {
"error": "invalid_client",
"error_description": "Unauthorized"
}
© www.soinside.com 2019 - 2024. All rights reserved.