简体   繁体   English

Google oauth2.0显示无效的客户端错误

[英]Google oauth2.0 showing Invalid client error

I'm trying to set up google Oauth in this application. 我正在尝试在此应用程序中设置google Oauth。 I've created config for both remote and production server. 我已经为远程服务器和生产服务器创建了配置。 It's working fine in the development env but getting this error in the production env which is Heroku. 它在开发环境中工作正常,但是在生产环境(即Heroku)中出现此错误。

gettin this error : 开始这个错误:

401. That’s an error.

Error: invalid_client

The OAuth client was not found.

Request Details
response_type=code
redirect_uri=https://vast-ridge-80091.herokuapp.com/auth/google/callback
scope=profile email
client_id=process.env.GOOGLE_CLIENT_ID

From this end point : https://vast-ridge-80091.herokuapp.com/auth/google 从这个终点来看: https : //vast-ridge-80091.herokuapp.com/auth/google

This is my config settings for the production environment 这是我在生产环境中的配置设置

module.exports = {

googleClientID:'process.env.GOOGLE_CLIENT_ID',
googleClientSecret:'process.env.GOOGLE_CLIENT_SECRET',
monoURI:'process.env.MONGO_URI',
cookieKey:'process.env.COOKIE_KEY'

};



if(process.env.NODE_ENV === 'production'){
module.exports = require('./prod');
}else{
module.exports = require('./dev');
}

I've updated the env variable in the heroku app settings and double checked everything, those credentials are correct. 我已经在heroku应用程序设置中更新了env变量,并仔细检查了所有内容,这些凭据是正确的。

This is my Heroku log : 这是我的Heroku日志:

remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 10.x...
remote:        Downloading and installing node 10.15.0...
remote:        Using default npm version: 6.4.1
remote:
remote: -----> Building dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > node-sass@4.11.0 install         
/tmp/build_e5f416e2f810c6ecc625fbcb71d64ab7/node_modules/node-sass
remote:        > node scripts/install.js
remote:
remote:        Downloading binary from https://github.com/sass/node-    
sass/releases/download/v4.11.0/linux-x64-64_binding.node
remote:        Download complete
remote:        Binary saved to     
/tmp/build_e5f416e2f810c6ecc625fbcb71d64ab7/node_modules/node-        
 sass/vendor/linux-x64-64/binding.node
remote:        Caching binary to /tmp/npmcache.hFNmC/node-sass/4.11.0/linux- 
x64-64_binding.node
remote:
remote:        > node-sass@4.11.0 postinstall     
/tmp/build_e5f416e2f810c6ecc625fbcb71d64ab7/node_modules/node-sass
remote:        > node scripts/build.js
remote:
remote:        Binary found at 
/tmp/build_e5f416e2f810c6ecc625fbcb71d64ab7/node_modules/node- 
sass/vendor/linux-x64-64/binding.node
remote:        Testing binary
remote:        Binary is fine
remote:        added 305 packages from 198 contributors and audited 811 
packages in 9.098s
remote:        found 0 vulnerabilities
remote:
remote:
remote: -----> Caching build
remote:        - node_modules
remote:
remote: -----> Pruning devDependencies
remote:        audited 811 packages in 2.556s
remote:        found 0 vulnerabilities
remote:
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote:        Done: 25.9M
remote: -----> Launching...
remote:        Released v3
remote:        https://vast-ridge-80091.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.

I've tried some solutions dicussed here : invalid_client in google oauth2 我尝试过这里讨论过的一些解决方案: google oauth2中的invalid_client

But still No luck. 但是仍然没有运气。

Any kind of help will be a bliss. 任何形式的帮助都是一种幸福。

The reply url 回复网址

https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=https://vast-ridge-80091.herokuapp.com/auth/google/callback&scope=profile email&client_id=process.env.GOOGLE_CLIENT_ID

contains and error on client_id 包含和client_id错误

client_id=process.env.GOOGLE_CLIENT_ID CLIENT_ID = process.env.GOOGLE_CLIENT_ID

You have to replace the process.env.GOOGLE_CLIENT_ID with the client_id 您必须将client.id替换为process.env.GOOGLE_CLIENT_ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM