0

Hello I am using Google Drive API and successfully generated its token.

json object looks like following:

{
 "access_token": xxxx,
 "refresh_token": xxxx,
 "token_type": "Bearer",
 "expiry_date": xxxx
}

I can successfully make request (i.e. download file) but I wonder about its expiration. I read through its API document and I don't understand few things.

  1. It looks like Refresh Token is not expired. Only access token expires. Am I correct?
  2. If #1 is correct, then should I remove all other fields other than "refresh_token"?

    { "refresh_token": xxxx }
    
  3. What I want to achieve is... keep one token which never expires. However after an hour, I tried to download file from Google Drive, but it returns following:

    {
     "access_token" : xxxx,
     "expires_in" : 3600,
     "token_type" : "Bearer"
    }
    

    It looks like it is expired. Do you need to generate token again for Google Drive API? There is no issue with Google Spreadsheet. Only Google Drive.

Thank you so much in advance.

Oh,, scope is

['https://www.googleapis.com/auth/drive.readonly']
ryan
  • 503
  • 2
  • 7
  • 17

1 Answers1

0
  1. Correct.
  2. The access_token should be valid for an hour or so (like what you mentioned in #3), so it should be safe discard it after that time frame. But wouldn't you want to keep it for logging reasons?
  3. Use the refresh_token to ask for another access_token.
AL.
  • 36,815
  • 10
  • 142
  • 281