Пример #1
0
        internal AuthorizationCodeCredential(string tenantId, string clientId, string clientSecret, string authorizationCode, TokenCredentialOptions options, MsalConfidentialClient client, CredentialPipeline pipeline = null)
        {
            Validations.ValidateTenantId(tenantId, nameof(tenantId));
            _tenantId = tenantId;
            Argument.AssertNotNull(clientSecret, nameof(clientSecret));
            Argument.AssertNotNull(clientId, nameof(clientId));
            Argument.AssertNotNull(authorizationCode, nameof(authorizationCode));
            _clientId    = clientId;
            _authCode    = authorizationCode;
            _pipeline    = pipeline ?? CredentialPipeline.GetInstance(options ?? new TokenCredentialOptions());
            _redirectUri = options switch
            {
                AuthorizationCodeCredentialOptions o => o.RedirectUri?.AbsoluteUri,
                                                   _ => null
            };

            _client = client ??
                      new MsalConfidentialClient(
                _pipeline,
                tenantId,
                clientId,
                clientSecret,
                _redirectUri,
                options as ITokenCacheOptions,
                null,
                options?.IsLoggingPIIEnabled ?? false);
        }
Пример #2
0
 /// <summary>
 /// Creates an instance of the ClientSecretCredential with the details needed to authenticate against Azure Active Directory with a prefetched authorization code.
 /// </summary>
 /// <param name="tenantId">The Azure Active Directory tenant (directory) Id of the service principal.</param>
 /// <param name="clientId">The client (application) ID of the service principal</param>
 /// <param name="clientSecret">A client secret that was generated for the App Registration used to authenticate the client.</param>
 /// <param name="authorizationCode">The authorization code obtained from a call to authorize. The code should be obtained with all required scopes.
 /// See https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow for more information.</param>
 /// <param name="options">Options that allow to configure the management of the requests sent to the Azure Active Directory service.</param>
 public AuthorizationCodeCredential(
     string tenantId,
     string clientId,
     string clientSecret,
     string authorizationCode,
     AuthorizationCodeCredentialOptions options) : this(tenantId, clientId, clientSecret, authorizationCode, options, null)
 {
 }
        internal AuthorizationCodeCredential(string tenantId, string clientId, string clientSecret, string authorizationCode, TokenCredentialOptions options, MsalConfidentialClient client)
        {
            Validations.ValidateTenantId(tenantId, nameof(tenantId));
            _tenantId = tenantId;
            Argument.AssertNotNull(clientSecret, nameof(clientSecret));
            Argument.AssertNotNull(clientId, nameof(clientId));
            Argument.AssertNotNull(authorizationCode, nameof(authorizationCode));
            _clientId = clientId;
            _authCode = authorizationCode;
            options ??= new TokenCredentialOptions();
            _pipeline    = CredentialPipeline.GetInstance(options);
            _redirectUri = options switch
            {
                AuthorizationCodeCredentialOptions o => o.RedirectUri?.ToString(),
                                                   _ => null
            };

            _client = client ?? new MsalConfidentialClient(_pipeline, tenantId, clientId, clientSecret, options as ITokenCacheOptions);
        }