I am trying to run OAuth2 using web applications hosted on Azure and cannot use service accounts (several solutions are available here, but they are all tied to service accounts / certificates), while I need a user for authentication and Log in with Google.
The code:
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = _clientId, ClientSecret = _clientSecret },
scopes,
User.Identity.Name,
CancellationToken.None,
new FileDataStore("GA.Auth.Store"))
.Result;
var service = new AnalyticsService(
new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Analytics API Sample"
});
It works locally, but throws this exception when deployed as an Azure web application:
[HttpListenerException (0x5): Access is denied]
Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +82
Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) +76
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__1.MoveNext() +233
I assume that GoogleWebAuthorizationBroker.AuthorizeAsync is trying to install an http listener, which (?) Is not possible in Azure web applications.
- Azure. , , Google?
: GA Real-Time, GA Reporting v3.