Esempio n. 1
0
        public static GmailService Create(GmailSettings settings, string userId)
        {
            BaseClientService.Initializer clientInitializer = new BaseClientService.Initializer
            {
                ApplicationName       = "Gmail file collector",
                HttpClientInitializer = CreateCredentials(settings, userId).GetAwaiter().GetResult()
            };

            return(new GmailService(clientInitializer));
        }
Esempio n. 2
0
        static Task <UserCredential> CreateCredentials(GmailSettings settings, string userId)
        {
            using (FileStream stream = new FileStream(settings.CredentialsPath, FileMode.Open, FileAccess.Read))
            {
                ClientSecrets secrets   = GoogleClientSecrets.Load(stream).Secrets;
                IDataStore    dataStore = new FileDataStore(settings.TokenPath, true);

                return(GoogleWebAuthorizationBroker.AuthorizeAsync(secrets, Scopes, userId, CancellationToken.None, dataStore));
            }
        }
Esempio n. 3
0
 public GmailAttachmentProvider(GmailSettings settings)
 {
     service = GmailServiceFactory.Create(settings, Constants.Me);
 }