title: Passing OAuth user data back to React via Node (Passport) authentication
body: <p>I'm a little confused about the flow of data in a React application that authorizes a user through a third party OAuth provider. Right now I have a login button in React that directs to a Node server.</p>
  
  <pre><code>&lt;a href="http://localhost:5000/api/auth/google" className="login-button"&gt;Log In&lt;/a&gt;
  </code></pre>
  
  <p>This directs to an Express route... </p>
  
  <pre><code>router.get('/auth/google',
      passport.authenticate('google', {
          session: false,
          scope: ['email']
      }));
  </code></pre>
  
  <p>that uses Passport to verify the login request.</p>
  
  <pre><code>passport.use(new GoogleStrategy({
          clientID: process.env.OAUTH_CLIENT_ID,
          clientSecret: process.env.OAUTH_SECRET,
          callbackURL: "http://localhost:5000/api/auth/google/callback"
      },
      function (accessToken, refreshToken, profile, cb) {
          return cb(null, profile);
      }
  ));
  </code></pre>
  
  <p>The callback is set up to redirect the user back to the React application.</p>
  
  <pre><code>router.get('/auth/google/callback',
      passport.authenticate('google', {
          session: false,
          failureRedirect: 'http://localhost:3000'
      }),
      function (req, res) {
          // Successful authentication, redirect home.
          res.redirect('http://localhost:3000');
      });
  </code></pre>
  
  <p>This method allows me to either add a user to my DB via my Node app, or confirm the existence of the user already in my DB, and that's as far as I've seen any tutorial take it, but it seems entirely useless without the ability to send this information back to React. The point of logging in, at least in my opinion, is to have my application function specific to a user.</p>
  
  <p>What I'd like to be able to do is send back a signed JWT token. Either one signed manually with my server, or the access token that passport gets from Google, either will do. As well, I'd like to send a user ID. I need this so my app can make API calls with the user ID as part of the request to protected routes, thus the need for the JWT.</p>
  
  <p>It's confusing to me because without this exchange of data, the purpose of OAuth seems essentially useless, so I must be missing a vital step in the process, or I must be looking at the problem from the wrong perspective. Where or how should I be informing my React application of the details of the logged in user, and give them a token for local storage? As far as I can tell, there's no way to send package of data back with the callback URL. </p>