Google-api-nodejs-client: Access token it is updated automatically?

Created on 19 Nov 2018  路  2Comments  路  Source: googleapis/google-api-nodejs-client

hello I've seen that the access token has a correct life time?

to test a certain code

oauth2client.on('tokens', (tokens) => {
  if (tokens.refresh_token) {
    // store the refresh_token in my database!
    console.log(tokens.refresh_token);
  }
  console.log(tokens.access_token);
});

to test it I'm sending a request to a google API (spreadsheet), with all the required authentication data, the only thing that changed is access_token as null, so you would get an answer as if you had sent an access_token expired.

But the surprise is, it returns a 200 status code, and performs the operation normally.

only the refresh token is necessary?

triage me question

Most helpful comment

Aye, that will work fine :) The way google-auth-library works is that if you set the refresh_token, it will auto-magically acquire an access token if one is not present, or if the access_token it has is expired. So yes - we update the access_token for you automatically :) Hope this answers your question!

All 2 comments

Aye, that will work fine :) The way google-auth-library works is that if you set the refresh_token, it will auto-magically acquire an access token if one is not present, or if the access_token it has is expired. So yes - we update the access_token for you automatically :) Hope this answers your question!

wow how amazing, thanks for clarifying.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ovaris picture ovaris  路  3Comments

streamnsight picture streamnsight  路  4Comments

Chethandsagar picture Chethandsagar  路  4Comments

skiod picture skiod  路  3Comments

ashishbajaj99 picture ashishbajaj99  路  3Comments