View GoogleAnalyticsOauth2
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
string[] scopes = new string[] { | |
AnalyticsService.Scope.Analytics, // view and manage your Google Analytics data | |
AnalyticsService.Scope.AnalyticsEdit, // Edit and manage Google Analytics Account | |
AnalyticsService.Scope.AnalyticsManageUsers, // Edit and manage Google Analytics Users | |
AnalyticsService.Scope.AnalyticsReadonly}; // View Google Analytics Data | |
var clientId = "[Client ID]"; // From https://console.developers.google.com | |
var clientSecret = "xxx"; // From https://console.developers.google.com | |
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData% | |
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, |
View GoogleAnalyitcsServiceAccount
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
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 = "xx@developer.gserviceaccount.com"; // 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)); |
View GoogleAnalyticsService
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
var service = new AnalyticsService(new BaseClientService.Initializer() { HttpClientInitializer = credential, | |
ApplicationName = "Analytics API Sample",}); |
View AnalyticsServicePublic
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
AnalyticsService services = new AnalyticsService(new BaseClientService.Initializer() | |
{ | |
ApiKey = "[API key]", // from https://console.developers.google.com (Public API access) | |
ApplicationName = "Analytics API Sample", | |
}); |
View GoogleSheetsCsharp
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
var certificate = new X509Certificate2(@"c:\Diamto Test Everything Project.p12", "notasecret", X509KeyStorageFlags.Exportable); | |
const string user = "XXX@developer.gserviceaccount.com"; | |
var serviceAccountCredentialInitializer = new ServiceAccountCredential.Initializer(user) {Scopes = new[] { "https://spreadsheets.google.com/feeds" } | |
}.FromCertificate(certificate); | |
var credential = new ServiceAccountCredential(serviceAccountCredentialInitializer); | |
if (!credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Result) |
View GoogleDriveOauth2Csharp
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
//Scopes for use with the Google Drive API | |
string[] scopes = new string[] { DriveService.Scope.Drive, | |
DriveService.Scope.DriveFile}; | |
var clientId = "[Client ID]"; // From https://console.developers.google.com | |
var clientSecret = "xxx"; // From https://console.developers.google.com | |
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData% | |
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, | |
ClientSecret = clientSecret}, | |
scopes, | |
Environment.UserName, |
View GoogleDriveServiceAccountcsharp
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
string[] scopes = new string[] {DriveService.Scope.Drive}; // Full access | |
var keyFilePath = @"c:\file.p12" ; // Downloaded from https://console.developers.google.com | |
var serviceAccountEmail = "xx@developer.gserviceaccount.com"; // 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)); |
View DriveServicecsharp
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
var service = new DriveService(new BaseClientService.Initializer() {HttpClientInitializer = credential, | |
ApplicationName = "Drive API Sample",}); |
View DriveServicecsharpPublic
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
var services = new DriveService(new BaseClientService.Initializer(){ | |
ApiKey = "[API key]", // from https://console.developers.google.com (Public API access) | |
ApplicationName = "Drive API Sample", | |
}); |
View Google Oauth email csharp
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
string _client_id = "[From Google Developer Console]"; | |
string _client_secret = "[From Google Developer Console]"; | |
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = _client_id, ClientSecret = _client_secret }, | |
new string[] {"email" }, | |
Environment.UserName , | |
CancellationToken.None, | |
new FileDataStore("Daimto.GooglePlus.Auth.Store")).Result; |
OlderNewer