private GoogleCredential GetCredentialFromFile() { var credentialFile = CredentialFile?.Render(LogEventInfo.CreateNullEvent()); if (string.IsNullOrWhiteSpace(credentialFile)) { return(null); } GoogleCredential credential = GoogleCredential.FromFile(credentialFile); if (credential.IsCreateScopedRequired) { credential = credential.CreateScoped(s_oAuthScopes); } return(credential); }
private GoogleCredential GetCredentialFromConfiguration() { var nullLogEvent = LogEventInfo.CreateNullEvent(); var credentialFile = CredentialFile?.Render(nullLogEvent); var credentialJson = CredentialJson?.Render(nullLogEvent); GaxPreconditions.CheckState(string.IsNullOrWhiteSpace(credentialFile) || string.IsNullOrWhiteSpace(credentialJson), $"{nameof(CredentialFile)} and {nameof(CredentialJson)} must not both be set."); var credential = !string.IsNullOrWhiteSpace(credentialFile) ? GoogleCredential.FromFile(credentialFile) : !string.IsNullOrWhiteSpace(credentialJson) ? GoogleCredential.FromJson(credentialJson) : null; if (credential == null) { return(null); } if (credential.IsCreateScopedRequired) { credential = credential.CreateScoped(s_oAuthScopes); } return(credential); }