public async Task <string> GetToken(IClientCredentialsConfig config)
 {
     if (config.Type == CredentialType.Secret)
     {
         return(await GetTokenWithSecret(config.Authority, config.Resource, config.ClientId, config.ClientSecret));
     }
     else
     {
         return(await GetTokenWithCertificate(config.Authority, config.Resource, config.ClientId, config.CertificateSubject));
     }
 }
Example #2
0
        private static async Task <Microsoft.Rest.ServiceClientCredentials> GetCredentials(IClientCredentialsConfig config, ITokenProvider tokenProvider)
        {
            try
            {
                var token = await tokenProvider.GetToken(config);

                return(new Microsoft.Rest.TokenCredentials(token));
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                //log.Error(message);
                throw;
            }
        }