title: Passport OAuth2 Callback URL Fires Twice
body: <p>I'm using Passport OAuth2 to authenticate with an API that currently does not have a custom Passport Strategy. My issue seems to be that the first GET request with the access code to <code>/auth/moxtra/callback?code=&lt;code here&gt;</code> hangs and never seems to resolve, which then causes a second GET request to the same URL to fire. At this point though, the access code has already been invalidated by the API, which causes a server error, so the user never gets redirected back to my application. Here's the output:</p>
  
  <pre><code>GET /auth/moxtra/callback?code=v-cqK8ywP2I - - ms - -
  GET /auth/moxtra/callback?code=v-cqK8ywP2I 500 665.180 ms - 1231
  </code></pre>
  
  <p>What's interesting is that I know the request works, since I'm logging the response I'm getting back; the desired resources that I'm querying for are successfully returned. But then the 500 server error blocks the redirect back to my application. </p>
  
  <p>I'm not completely sure this is a Passport error, but I've been talking to the backend guy who manages the API and from his testing, he doesn't think it's an issue on his end. </p>
  
  <p>I'd greatly appreciate any ideas/feedback!</p>
  
  <p>EDIT: Here's the code for the OAuth strategy:</p>
  
  <pre><code>passport.use('moxtra', new OAuthStrategy({
    authorizationURL: 'https://api.moxtra.com/oauth/authorize',
    tokenURL: 'https://api.moxtra.com/oauth/token',
    clientID: configAuth.moxtraAuth.clientID,
    clientSecret: configAuth.moxtraAuth.clientSecret,
    callbackURL: configAuth.moxtraAuth.callbackURL
  },
  function(accessToken, done) {
    console.log("Access token: ", accessToken);
    var url = 'https://api.moxtra.com/me?access_token=' + accessToken;
    request.get(url, function(err, response, body) {
      if (!err &amp;&amp; response.statusCode == 200) {
        console.log("Response body: ", body);
      }
    });
  }));
  </code></pre>
  
  <p>And here's the route middleware code:</p>
  
  <pre><code>app.get('/auth/moxtra', passport.authenticate('moxtra'));
  
  app.get('/auth/moxtra/callback', passport.authenticate('moxtra', {
    successRedirect : '/profile',
    failureRedirect : '/',
    failureFlash : true
  }));
  </code></pre>
  
  <p>Currently I'm just logging the access token and response body to the console. Both are successfully returning. I have no idea what's causing the first GET request to not resolve. </p>