Skip to content

Instantly share code, notes, and snippets.

@LindaLawton
Created July 22, 2015 07:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LindaLawton/8c089577827bbc42986a to your computer and use it in GitHub Desktop.
Save LindaLawton/8c089577827bbc42986a to your computer and use it in GitHub Desktop.
accessing google drive with a service account and C#
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));
@AshV
Copy link

AshV commented Sep 17, 2017

Can you please help with JSON key, instead of p12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment