我正在尝试在此应用程序中设置google Oauth。我已经为远程服务器和生产服务器创建了配置。在开发环境中可以正常工作,但在生产环境(即Heroku)中会收到此错误。
得到这个错误:
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
从此结束:https://vast-ridge-80091.herokuapp.com/auth/google
这是我在生产环境中的配置设置
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');
}
我已经在heroku应用程序设置中更新了env变量,并仔细检查了所有内容,这些凭据都是正确的。
这是我的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.
我尝试过这里讨论过的一些解决方案:invalid_client in google oauth2
但仍然没有运气。
任何一种帮助都是一种幸福。
答案 0 :(得分:0)
回复网址
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
包含 client_id
并出错client_id = process.env.GOOGLE_CLIENT_ID
您必须将process.env.GOOGLE_CLIENT_ID
替换为client_id