Hello everyone I have used this code for User Auth by Google Auth and retrieved the token But I have faced an issue this token has expired only 5 min . I want this token is not expire.
Loading
Hello everyone I have used this code for User Auth by Google Auth and retrieved the token But I have faced an issue this token has expired only 5 min . I want this token is not expire.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jayraj ChhayaPosted Apr 16, 2024, 6:53 AM
To handle the issue of the token expiring after 5 minutes, you need to implement a mechanism to refresh the token before it expires. This can be achieved by using the Google API client library for .NET.
Here's an example of how you can modify your code to refresh the token:
we retrieve the refresh token from the authentication tokens obtained from Google. We then create a new instance of the Google API client and set the access token and refresh token. We check if the access token is about to expire (within 5 minutes) and if so, we refresh the token using the
RefreshTokenAsyncmethod. Finally, we update the existing record with the new access token.By implementing this token refresh mechanism, you can ensure that the token does not expire and the user can continue to use the Google Authentication without interruption.
Sourabh DhimanPosted Apr 16, 2024, 5:49 AM
This is my code