How to be notified when go google api refreshes access and refresh token?

WBOY
Release: 2024-02-10 21:57:07
forward
732 people have browsed it

当 go google api 刷新访问和刷新令牌时如何收到通知?

php editor Youzi often encounters refresh access and refresh tokens when using go google api. But how do you get notified in time? In fact, we can do this by setting the callback URL. When the refresh operation completes, Google will send a POST request to this URL to notify us of the status of the refresh. In this way, we can obtain relevant information about access and token refresh in time to facilitate our subsequent processing and operations.

Question content

My application successfully obtains AccessToken and RefreshToken from the user through the oauth2 process. I then store them in the database so that I can access them later and perform requests on behalf of the user. So far this is working fine. But when my AccessToken expires, the Go google api library automatically refreshes the AccessToken along with the RefreshToken using that RefreshToken. This works great too, but to be able to use the new set of tokens in future sessions I have to store them in my database again. So how can I make the Go google api tell me when the access token is changed?

In the example of their node.js library, there is a simple callback that I can register to achieve this. But somehow the documentation for Go libraries is not that good.

Google official documentation: https://developers.google.com/identity/protocols/oauth2/web-server?hl=de#offline

Solution

In-depth study of golang/ After oauth2 code, I found that there is no such function. However, I opened a pull request on the above repository to enable it. https://www.php.cn/link/8fbf752a03d27d94c949ca816b453196

The above is the detailed content of How to be notified when go google api refreshes access and refresh token?. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!