I have been using the Google API Client Library for .NET for loading Google Analytics data into my application:
Recently though I have found it to have started freezing up completely. The Execute()
command makes a connection to the Google server.
It makes a successful request to :
https://accounts.google.com/o/oauth2/token
which returns something like :
{
"access_token" : "ya30.HAKlQSGZo2GnK5wxlxx9TLTQUyD9Xkt7AZxuQnDY-KhJuCyrCtN_xHIP",
"token_type" : "Bearer",
"expires_in" : 3600
}
But then never returns from the Execute
call.
The same code in a console app returns immediately, but in IIS it is currently never returning.
In a previous version it worked just fine (I'm not exactly sure which version it changed).
I have Load User Profile
set to true.
What could be causing this?
var SERVICE_ACCOUNT_PKCS12_FILE_PATH = @"C:\TEMP\GoogleAnalytics-privatekey.p12";
X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
// Create credentials (not my real login here)
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer("86987278011-ctegcus4og7kn6oigkrv8po5pf67bbgj@developer.gserviceaccount.com")
{
Scopes = new[] { AnalyticsService.Scope.AnalyticsReadonly }
}.FromCertificate(certificate));
// Create the service
var service = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Google Analytics Application",
});
// get accounts
accounts = service.Management.Accounts.List();
var items = accounts.Execute();