Reputation: 222
I want to get the refresh token from the google Api's but i don't know how i can get this Please anyone can tell me
Upvotes: 0
Views: 864
Reputation: 592
Check this answer on getting Google Refresh Token or check the official documentation on Google Api
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 set the refresh_token at a later time, you can use the setCredentials method:
oauth2Client.setCredentials({
refresh_token: `STORED_REFRESH_TOKEN`
});
Once the client has a refresh token, access tokens will be acquired and refreshed automatically in the next call to the API.
Note: You should also know that The refresh_token is only returned on the first authorization.
Upvotes: 2