0
Follow
0
View

How to get refresh token from the 0auth2.0 in nodejs app

dickens_csl 注册会员
2023-01-25 21:35

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.

You should also know that The refresh_token is only returned on the first authorization.

About the Author

Question Info

Publish Time
2023-01-25 21:35
Update Time
2023-01-25 21:35

Related Question

怎么设置QtPushButton的背景图片?

switch to postman desktop agent to connect with a websocket server

Grid GetColumnState - flex始终为空

Azure DataFactory create folder dynamically and create json file

creator_trx_id存储在readview吗

cocos creator 怎么监听场景内有没有敌人

Offset和Limit在GET API中不起作用

如何在springboot中使用MongoRepository查找Mongo集合的特定字段的平均值?

在Yocto中重写固件安装配方

冻结包不能为嵌套对象生成toJson代码