Reputation: 168
I try to use this code for getting Google refresh token for the application with Google.Apis.Auth.OAuth2 library. When I use it on localhost, it is worked perfect, but when I use it under an Azure site it will be throw System.AggregateException with Access is denied InnerException.
UserCredential credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets()
{
ClientId = "<client_id>",
ClientSecret = "<client_secret>"
},
new string[] { },
Environment.UserName,
CancellationToken.None,
null
).Result;
string refreshToken = credential.Token.RefreshToken;
The inner exception is:
InnerException Message: Access is denied at System.Net.HttpListener.SetupV2Config() at System.Net.HttpListener.Start() at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext()
Is there any other way to get refresh token?
Thanks!
Upvotes: 3
Views: 572
Reputation: 2933
Have you configured the Azure URI as authorised in the Google console API manager?
Upvotes: 0