我正在使用passport-google-oauth 运行node.js。来自我的 package.json:
"passport-google-oauth": "~1.0.0",
我遵循了本教程:https://scotch.io/tutorials/easy-node-authentication-google
在Google API中,我建立了一个项目,并在express.js javascript中使用client-id、client-secret。我还在 google API 和我的 javascript 中使用相同的重定向 url。 还要在授权的 JavaScript 来源中设置我的网络应用程序 url
当我尝试使用我的谷歌帐户登录时,我被带到一个谷歌页面,然后我按“允许”,该页面被重定向到我的重定向网址。然后,我得到这个(从堆栈跟踪中省略路径):
未经授权 500
令牌错误:未经授权
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)
有人经历过这种情况或者知道问题可能是什么吗?
这最终导致了复制粘贴错误:当我从谷歌复制密钥时,我用空格复制了它。如果有人遇到过这种情况 - 只需删除末尾的空格即可。