how to use the refreshAccessToken method to generate a new accesstoken in google-api-nodejs-client

后端 未结 2 2038
孤城傲影
孤城傲影 2021-01-20 18:37

I see that this pull request adds a method to refresh the access token using a saved refresh token. It is not clear to me how to use it. I have saved the tokens (including t

2条回答
  •  春和景丽
    2021-01-20 19:33

    Just a guess as I haven't used this library. But it looks to me like you simply call myOAuth2Client.refreshAccessToken(function(err, newCredentials){}), where you have already instantiated the OAuth2Client object with the old token. (dunno how you do that but it might be as simple as instantiating the object then myOauth2Client.credentials.refresh_token = 'foobar'.) And if there's no error, it'll modify the OAuth2Client.credentials object and additionally pass the credentials object to the callback.

提交回复
热议问题