Esempio n. 1
0
 public GoogleAPI(AccountGoogle account)
 {
     // Create Google Sheets API service.
     this.service = new SheetsService(new BaseClientService.Initializer()
     {
         HttpClientInitializer = this.getCredential(account),
         ApplicationName       = ApplicationName,
     });
 }
Esempio n. 2
0
        private UserCredential getCredential(AccountGoogle account)
        {
            UserCredential credential;
            string         credPath = "token.json";

            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
            {
                ClientId     = account.ClientId,
                ClientSecret = account.ClientSecret
            },
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
            Console.WriteLine("Credential file saved to: " + credPath);


            return(credential);
        }