public GoogleSheetsService(IServiceProvider serviceProvider)
        {
            IConfiguration configuration = serviceProvider.GetService <IConfiguration>();

            _credentialType  = Enum.Parse <GoogleCredentialType>(configuration["Google:Credential:Type"]);
            _credentialsPath = configuration["Google:Credential:File"];

            Console.WriteLine($"Google API Credential Type: {_credentialType.ToString()}");
        }
 private ICredential GetCredential(GoogleCredentialType credentialType, string credentialsPaht)
 {
     if (credentialType == GoogleCredentialType.User)
     {
         return(GetUserCredential(credentialsPaht));
     }
     else
     {
         return(GetServiceCredential(credentialsPaht));
     }
 }
Exemple #3
0
 /// <summary>
 /// Creates credentials representing a login using a Google account.
 /// </summary>
 /// <param name="credential">The credential representing the Google user.</param>
 /// <param name="type">The type of the credential.</param>
 /// <returns>A Credentials that can be used to authenticate a user with Google.</returns>
 /// <seealso href="https://docs.mongodb.com/realm/authentication/google/">Google Authentication Docs</seealso>
 public static Credentials Google(string credential, GoogleCredentialType type)
 {
     Argument.NotNull(credential, nameof(credential));
     return(new Credentials(AuthProvider.Google, credential, type.ToString()));
 }