0

我正在使用passport-google-oauth 运行node.js。从我的 package.json 中:

"passport-google-oauth": "~1.0.0",

我遵循了本教程:https ://scotch.io/tutorials/easy-node-authentication-google

在谷歌 API 中,我建立了一个项目,并在我的 express.js javascript 中使用了客户端 ID、客户端密钥。我还在 google API 和我的 javascript 中使用相同的重定向 url。还要在 Authorized JavaScript origins 中设置我的 web-app url

当我尝试使用我的谷歌帐户登录时,我被带到一个谷歌页面,然后我按“允许”,该页面被重定向到我的重定向网址。然后,我得到了这个(来自堆栈跟踪的省略路径):

未经授权的 500

TokenError:未经授权

at Strategy.OAuth2Strategy.parseErrorResponse 
at Strategy.OAuth2Strategy._createOAuthError
at node_modules/passport-google-oauth/node_modules/passport-google-oauth20/node_modules/passport-oauth2/lib/strategy.js:166:45
at node_modules/passport-google-oauth/node_modules/passport-google-oauth20/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:177:18
at passBackControl 
at IncomingMessage.<anonymous>
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)

有没有人经历过这个或知道问题可能是什么?

4

1 回答 1

1

这最终变成了一个愚蠢的复制粘贴:当我从谷歌复制密钥时,我复制了一个空格。如果有人发生这种情况 - 只需从末尾删除空间。

于 2016-08-25T00:34:31.870 回答