title: verify a google id token and use data from callback in node.js
body: <p>In my react app I retrieve an authorization token from google and send it to my back end to verify it. I followed <a href="https://developers.google.com/identity/sign-in/web/backend-auth" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/web/backend-auth</a> to achieve this, but I need to use the data I get in the callback outside of the callback:</p>
  
  <pre><code>const clientId = '&lt;MyAppId&gt;';
  var auth = new GoogleAuth;
  var client = new auth.OAuth2(clientId, '', '');
  client.verifyIdToken(
      input.googleAuthToken,
      clientId,
      function (e, login){
         if (login) {
             var payload = login.getPayload();
             var googleId = payload['sub'];
             console.log(googleId); //correct id is logged
         }
      }
  );
  //I need the 'googleId' here
  </code></pre>
  
  <p>So this is working, but I need the googleId outside of the callback to check it with my database. How would I achieve this?</p>