示例#1
0
        public Drive(IServiceAccountApplication saApp)
        {
            credential = DriveCredentialsService.GetServiceAccountCredential(saApp);
            service    = DriveCredentialsService.GetService(saApp);

            application = saApp;
        }
示例#2
0
        public static ServiceAccountCredential GetServiceAccountCredential(IServiceAccountApplication saApp)
        {
            var certificate = new X509Certificate2(saApp.PrivateKey, "notasecret", X509KeyStorageFlags.Exportable);
            ServiceAccountCredential credential = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(saApp.ServiceAccountMail)
            {
                Scopes = new[] { DriveService.Scope.DriveFile, DriveService.Scope.Drive }
            }.FromCertificate(certificate));

            return(credential);
        }
示例#3
0
 public static DriveService GetService(IServiceAccountApplication saApp)
 {
     return(GetService(GetServiceAccountCredential(saApp), saApp));
 }