title: Nodejs Google Drive API
body: <p>I am trying to understand how the authorization(particular the refresh tokens) working for nodejs Google Drive API.</p>
  
  <p>Here it's the code from <a href="https://github.com/google/google-api-nodejs-client" rel="nofollow">https://github.com/google/google-api-nodejs-client</a>.</p>
  
  <pre><code>    oauth2Client.credentials = {
        access_token: 'ACCESS TOKEN HERE',
        refresh_token: 'REFRESH TOKEN HERE'
      };
  
      client
        .plus.people.get({ userId: 'me' })
        .withAuthClient(oauth2Client)
        .execute(callback);
  </code></pre>
  
  <p>General Question:
  How does refresh tokens actually work together with access token? </p>
  
  <p>Background:
  As what I interpret is that each access token has a limited timespan (~1 hr). So when a user FIRST connect to my server (which the server provides mechanism for user authentication), the server receives limited-life access token and ONE-TIME refresh token. After 1 hour, the access token is expired.</p>
  
  <p>Specific question:
  Here comes to the key questions. After the expiration, my server stills send request to the Google Drive Api with the EXPIRED access token and refresh token (Server uses session to store those values). Will this still be able to access the content in Google Drive? What I am guessing is that the nodejs lib + google drive api is SMART enough to detect the access token is expired &amp; refresh token is identified &amp; api replace the expired access token with new access token blindly (like server does not need to do anything; just google drive api). Will the api response the server with a new Access Code?</p>
  
  <p>I need to figure this out because I need to organize my code in Nodejs effectively. </p>
  
  <p>Thanks!</p>