I have a report application that uses the adsense api. I am using GoogleWebAuthorizationBroker.AuthorizeAsync for authentication. When i wun it locally it works fine, the request for permission window opens and after I grant access everything works My problem is when I deploy it to the production server and it runs on IIS the GoogleWebAuthorizationBroker.AuthorizeAsync hangs forever. My guess is that it's trying to open the authorization window on the server and is unable to do that. I did not write this implementation and it has been in production for a while now and it used to work fine. I'm not sure what happened and if somthing changed, but it doesn't work now. I surfed around and tryied different aproaches bot none worked. When I tried using GoogleAuthorizationCodeFlow with the AccessType set to "offline" and with the provided URI it still didn't work. I also tried using a Service Account but I later learned that they are not suported for adsense. Below is the codesample
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = ConfigurationManager.AppSettings["AdSenseClientId"],
ClientSecret = ConfigurationManager.AppSettings["AdSenseClientSecret"]
},
new string[] { AdSenseService.Scope.Adsense },
"xxxxxxxx@gmail.com",
CancellationToken.None).Result;
// Create the service.
adSenseService = new AdSenseService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "My API Project"
});
var adClientRequest = adSenseService.Adclients.List();
var adClientResponse = adClientRequest.Execute();
I would be very greatfull for a sample code that solves this. I saw this post (ASP.NET MVC5 Google APIs GoogleWebAuthorizationBroker.AuthorizeAsync works locally but not deployed to IIS), but it doesn't have a code sample and it didn't help me.
Thank you in advance.