Skip to content
Advertisement

Access Token Expires while using Google Oauth 2.0 API after some time [closed]

I started using Google Oauth 2.0 code in order to work on Google calendars for my project.
Everything works perfectly and then suddenly after some time or almost a day the Access Token expires I tried using the refresh token where I’m storing the refresh token in my DB and using the same to get a new access token every time.

It’d be a huge help if someone could help me out with this.
My project is built in PHP ( Laravel ).

Access Token Error Screenshot

Advertisement

Answer

Try to follow these steps:

Step 1. If the Access Token fails, use the current Refresh Token to request new Access and Refresh Tokens.

Step 2. Store BOTH the Access and Refresh Tokens that are returned.

Step 3. Use the new Access Token for making Online API calls.

Step 4. When the Access Token fails in 1 hour, go to Step 1.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement