title: Why am I getting a TokenError when authenticating with OAuth2Strategy for Passport/Node Express
body: <p>I'm trying to use the OAuth2Strategy for Passport JS in conjunction with Express (4). </p>
  
  <p>After I'm redirected to to login, it successfully navigates me back to my callback url, at which point I get the following error:</p>
  
  <pre><code>TokenError: Invalid client or client credentials
      at OAuth2Strategy.parseErrorResponse (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:298:12)
      at OAuth2Strategy._createOAuthError (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:345:16)
      at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:171:43
      at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:177:18 at passBackControl (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:124:9)
      at IncomingMessage.&lt;anonymous&gt; (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:143:7)
      at IncomingMessage.EventEmitter.emit (events.js:117:20)
      at _stream_readable.js:919:16
      at process._tickDomainCallback (node.js:463:13)
  </code></pre>
  
  <p>My passport configuration is as follows:</p>
  
  <pre><code>passport.use("avatarz", new OAuth2Strategy({
          authorizationURL: authorizationURL,
          tokenURL: tokenURL,
          clientID: clientID,
          clientSecret: clientSecret,
          callbackURL: callbackURL
      },
      function (accessToken, refreshToken, profile, done) {
          User.find({
              prid: profile.prid
          }, function (error, user) {
              if (error) {
                  return done(error);
              }
  
              if (user) {
                  return done(null, user);
              }
              else {
                  done(error);
              }
          });
      }
  ));
  </code></pre>
  
  <p>And my routes are as follows:</p>
  
  <pre><code>app.get('/authentication/provider', passport.authenticate("avatarz"));
  
  app.get('/', passport.authenticate("avatarz", { failureRedirect: '/authentication/provider' }),
  function (req, res) {
      res.sendfile("./public/index.html");
  });
  </code></pre>
  
  <p>Any help/advice would be greatly appreciated! </p>