【发布时间】:2020-02-07 22:39:56
【问题描述】:
我正在使用 OAuth Google API,我得到了401 Error: invalid_client。
这与 clientID 或 clientSecret 代码无关,因为我确信我完美地复制了密钥。我再次创建了一个新凭据以确保它不是 Google API 的问题,但错误仍然存在。当我运行服务器时,我也没有在控制台中收到任何错误。有人可以帮帮我吗?
这是我从浏览器收到的:
> 401. That’s an error. > > Error: invalid_client > > The OAuth client was not found. > > Request Details > response_type=code > redirect_uri=http://localhost:5000/auth/google/callback > scope=profile email > client_id=keys.googleClientID > That’s all we know.
这是我的代码的一部分:
passport.use(
new GoogleStrategy(
{
clientID: 'keys.googleClientID',
clienSecret: 'keys.googleClientSecret',
callbackURL: '/auth/google/callback'
},
(accessToken, refreshToken, profile, done) => {
console.log('access token', accessToken);
console.log('refresh token', refreshToken);
console.log('profile', profile);
}
)
);
app.get(
'/auth/google',
passport.authenticate('google',{
scope: ['profile', 'email']
})
);
app.get('/auth/google/callback', passport.authenticate('google'));
谢谢! :)
【问题讨论】:
-
invalid_client 表示客户端 ID 和/或密码对您正在使用的代码无效。(未找到 OAuth 客户端 google 并没有对您撒谎)所以它肯定有一些东西与客户有关。如果您确定您正确复制了它们并且没有在开发控制台上删除它们。您创建了哪种类型的客户端?
-
感谢您的回答,但是客户类型是什么意思?
-
我不是节点期望但你不是发送字符串keys.googleClientID
标签: javascript node.js oauth google-oauth google-developers-console