Created
July 20, 2015 09:49
-
-
Save LindaLawton/79b140b1fdb6fd1d19a5 to your computer and use it in GitHub Desktop.
Connect to Google Analytics with a service account and the Google .net Client library
This file contains hidden or 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
string[] scopes = new string[] {AnalyticsService.Scope.Analytics}; // view and manage your Google Analytics data | |
var keyFilePath = @"c:\file.p12" ; // Downloaded from https://console.developers.google.com | |
var serviceAccountEmail = "[email protected]"; // found https://console.developers.google.com | |
//loading the Key file | |
var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable); | |
var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { | |
Scopes = scopes}.FromCertificate(certificate)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment