Created
May 11, 2015 17:59
-
-
Save mskutta/5849165ef99f49418995 to your computer and use it in GitHub Desktop.
Social Sort Manager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private AnalyticsService GetService() | |
{ | |
// Google Analytics API Service Account Authentication | |
var keyFilePath = _settings.GoogleAnalyticsKeyFilePath; // found in developer console under APIs & auth / Credentials | |
var serviceAccountEmail = _settings.GoogleAnalyticsServiceAccountEmail; // found in developer console under APIs & auth / Credentials | |
var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable); // notasecret is the standard password for the key file. | |
var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail) | |
{ | |
Scopes = new[] { AnalyticsService.Scope.AnalyticsReadonly } | |
}.FromCertificate(certificate)); | |
// Google Analytics Service | |
var service = new AnalyticsService(new BaseClientService.Initializer | |
{ | |
HttpClientInitializer = credential, | |
ApplicationName = "OneNorth.SocialSort", // This can be whatever you want | |
}); | |
return service; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment