panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

"OPError: invalid_client" after signin screen when using passport strategy #192

Closed Talwynox closed 5 years ago

Talwynox commented 5 years ago

Hi, I keep getting

OPError: invalid_client (The OAuth client was not found.)

after the signin screen when using this passport strategy. I already checked the client and clientsecret. (the passport-google-oauth strategy with the same id and secret is working fine)

 const openIDCallback = (tokenSet, profile, done) => {
    done(null, profile);
  };

  Issuer.discover('https://accounts.google.com') 
    .then(function(googleIssuer) {
      let opts = {};
      const client = new googleIssuer.Client({
          clientID: process.env.GOOGLE_KEY,
          clientSecret: process.env.GOOGLE_SECRET,
        });
        const params = {
          client_id: process.env.GOOGLE_KEY,
          response_type: 'code',
          scope: 'openid profile email',
          redirect_uri: 'https://localhost:8080/openID/callback'
        };
        opts.client = client;
        opts.params = params;

        passport.use('openid', new OICStrategy(opts, openIDCallback));
    });

const addSocketIdtoSession = (req, res, next) => {
  req.session.socketId = req.query.socketId;
  next();
};

const openIDConnectAuth = passport.authenticate('openid');
router.get("/openID", addSocketIdtoSession, openIDConnectAuth);
router.get('/openID/callback', openIDConnectAuth, authController.openID);
panva commented 5 years ago
clientID: process.env.GOOGLE_KEY,
clientSecret: process.env.GOOGLE_SECRET,

this is not valid for the client constructor