0

I'm trying to set up google Oauth in this application. 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.

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

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.

This is my Heroku log :

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

But still No luck.

Any kind of help will be a bliss.

MDIPANJAN
  • 115
  • 2
  • 9
  • Check the **reply url** in the google app – Max Jan 19 '19 at 16:18
  • This is the reply url : https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=https%3A%2F%2Fvast-ridge-80091.herokuapp.com%2Fauth%2Fgoogle%2Fcallback&scope=profile%20email&client_id=process.env.GOOGLE_CLIENT_ID @Max – MDIPANJAN Jan 19 '19 at 19:09
  • The redirect_uri on the url you posted is: `https://vast-ridge-80091.herokuapp.com/auth/google/callback` is this correct for both remote and production ? – Max Jan 21 '19 at 10:13

1 Answers1

0

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=process.env.GOOGLE_CLIENT_ID

You have to replace the process.env.GOOGLE_CLIENT_ID with the client_id

Max
  • 6,821
  • 3
  • 43
  • 59
  • Actually the GOOGLE_CLIENT_ID is coming from the heroku, the environment variables and secrets are are saved into it . @Max – MDIPANJAN Jan 23 '19 at 07:08