'Google Refresh Token throws Expire Error in Azure
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows for full read/write access to the
// authenticated user's account.
new[] { YouTubeService.Scope.Youtube },
"user",
CancellationToken.None,
new FileDataStore(this.GetType().ToString())
);
}
Using the code I shared above, I can renew the duration of the refresh token and create a campaign through Google Ads SDK (for Net 5 application) without any problems, but when I launch the same application in Azure Containers, I get a "Token Expire" error.
I will be very happy if you can help me with this behavior difference. Thank you in advance.
Kind regards
Solution 1:[1]
The error ("Token Expire") shows that the Token is expired so you have to check the expiration period or create a new Token.
You can follow the below step to Refresh auth token
When the provider's Access token expires you need to reauthenticate the user before you use it.
Avoid Token expiration using the GET call to the
/.auth/refreshendpoint of your application.When App Service is invoked, the access tokens in the token store for the authorized user are automatically refreshed. Following requests for tokens from your app code, the tokens are updated. However, for a token refresh to work, your provider's refresh tokens must be present in the token storage.
Append the
access_type=offlinein a query string parameter to your login API call (/.auth/login/google).
Refer here for more information
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DelliganeshS-MT |
