title: How to use the node google client api to get user profile with already fetched token?
body: <p>Getting a user profile info through <strong>curl</strong></p>
  
  <pre><code>curl -i https://www.googleapis.com/userinfo/v2/me -H "Authorization: Bearer a-google-account-access-token"
  </code></pre>
  
  <p>Getting a user profile info through <strong>node https get request</strong></p>
  
  <pre><code>const https = require('https');
  
  function getUserData(accessToken) {
      var options = {        
                      hostname: 'www.googleapis.com',
                      port: 443,
                      path: '/userinfo/v2/me',
                      method: 'GET',
                      json: true,
                      headers:{
                          Authorization: 'Bearer ' + accessToken            
                     }
              };
      console.log(options);
      var getReq = https.request(options, function(res) {
          console.log("\nstatus code: ", res.statusCode);
          res.on('data', function(response) {
              try {
                  var resObj = JSON.parse(response);
                  console.log("response: ", resObj);
              } catch (err) {
                  console.log(err);
              }
          });
      });
  
      getReq.end();
      getReq.on('error', function(err) {
          console.log(err);
      }); 
  
  }
  
  var token = "a-google-account-access-token";
  getUserData(token)
  </code></pre>
  
  <p>How can I use this <a href="https://github.com/google/google-api-nodejs-client" rel="noreferrer">google node api client library</a> to get the user profile info <strong>provided that I already have the access token</strong>? I can use the code above to get the profile but I thought it's probably better off to use the google api library to do it, but I can't figure out how to do that using this node google api client library.</p>
  
  <p>A temporary access token can be acquired through playing this <a href="https://developers.google.com/oauthplayground/?code=4/qt6dCgnmWpcVvdLdoXuoPx13oZ9eBR08ZJ_xTrMXM6A#" rel="noreferrer">playground</a> </p>