Passport js Error 401: invalid_client The OAuth client was not found

Viewed 991

I am using Passport js in Express for authenticating user with Google. I am using Passport for oauth servicing and passport-google-oauth20 for GoogleStrategy and i am using Express for server side. So following is my code ....

const express = require('express')
const passport = require('passport')
const GoogleStrategy = require('passport-google-oauth20').Strategy
const key = require('./config/key')
const app = express()

  passport.use(new GoogleStrategy({
    clientID: key.googleClientSecret,
    clientSecret: key.googleClientSecret,
    callbackURL: '/auth/google/callback'
  },(accessToken)=>{
     console.log(accessToken)
  })
)

app.get('/auth/google',passport.authenticate('google', {
   scope: ['profile','email']
}))

app.get('/auth/google/callback',passport.authenticate('google'))

const PORT = process.env.PORT || 5000
app.listen(PORT)

and following is my package.json script

"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}

i am using nodemon for auto running server. And i have also create project in google.developers.console for client_id and client_secret. But when i run the server it just redirect me to the following url and show the following error.

url: https://accounts.google.com/signin/oauth/error?authError=Cg5pbnZhbGlkX2NsaWVudBIfVGhlIE9BdXRoIGNsaWVudCB3YXMgbm90IGZvdW5kLiCRAw%3D%3D&client_id=z02cLybsfbgFxwA3d60Iuc5u

error: enter image description here

1 Answers
    clientID: key.googleClientSecret,
    clientSecret: key.googleClientSecret,

You set the googleClientSecret as the clientID. That doesn't seem right :)

Related