Exemple #1
0
        public AuthenticationRequestParameters(
            IServiceBundle serviceBundle,
            AcquireTokenCommonParameters commonParameters,
            RequestContext requestContext)
        {
            _commonParameters = commonParameters;

            Authority = commonParameters.AuthorityOverride == null
                ? serviceBundle.Config.Authority
                : commonParameters.AuthorityOverride;

            ClientId       = serviceBundle.Config.ClientId;
            Scope          = ScopeHelper.CreateSortedSetFromEnumerable(commonParameters.Scopes);
            RedirectUri    = serviceBundle.Config.RedirectUri;
            RequestContext = requestContext;

            // Set application wide query parameters.
            ExtraQueryParameters = serviceBundle.Config.ExtraQueryParameters ?? new Dictionary <string, string>();

            // Copy in call-specific query parameters.
            if (commonParameters.ExtraQueryParameters != null)
            {
                foreach (var kvp in commonParameters.ExtraQueryParameters)
                {
                    ExtraQueryParameters[kvp.Key] = kvp.Value;
                }
            }
        }
        public async Task <AuthenticationResult> ExecuteAsync(
            AcquireTokenCommonParameters commonParameters,
            AcquireTokenByRefreshTokenParameters refreshTokenParameters,
            CancellationToken cancellationToken)
        {
            var requestContext = CreateRequestContextAndLogVersionInfo();

            if (commonParameters.Scopes == null || !commonParameters.Scopes.Any())
            {
                commonParameters.Scopes = new SortedSet <string>
                {
                    _clientApplicationBase.AppConfig.ClientId + "/.default"
                };
                requestContext.Logger.Info(LogMessages.NoScopesProvidedForRefreshTokenRequest);
            }

            var requestParameters = _clientApplicationBase.CreateRequestParameters(
                commonParameters,
                requestContext);

            requestParameters.IsRefreshTokenRequest = true;

            requestContext.Logger.Info(LogMessages.UsingXScopesForRefreshTokenRequest(commonParameters.Scopes.Count()));

            var handler = new ByRefreshTokenRequest(ServiceBundle, requestParameters, refreshTokenParameters);

            return(await handler.RunAsync(CancellationToken.None).ConfigureAwait(false));
        }
Exemple #3
0
 internal virtual AuthenticationRequestParameters CreateRequestParameters(
     AcquireTokenCommonParameters commonParameters,
     RequestContext requestContext)
 {
     return(new AuthenticationRequestParameters(
                ServiceBundle,
                commonParameters,
                requestContext));
 }
        public async Task <AuthenticationResult> ExecuteAsync(
            AcquireTokenCommonParameters commonParameters,
            AcquireTokenSilentParameters silentParameters,
            CancellationToken cancellationToken)
        {
            var requestContext = CreateRequestContextAndLogVersionInfo();

            var requestParameters = _clientApplicationBase.CreateRequestParameters(
                commonParameters,
                requestContext);

            var handler = new SilentRequest(ServiceBundle, requestParameters, silentParameters);

            return(await handler.RunAsync(cancellationToken).ConfigureAwait(false));
        }
Exemple #5
0
        public async Task <AuthenticationResult> ExecuteAsync(
            AcquireTokenCommonParameters commonParameters,
            AcquireTokenInteractiveParameters interactiveParameters,
            CancellationToken cancellationToken)
        {
            var requestContext = CreateRequestContextAndLogVersionInfo();

            var requestParams = _publicClientApplication.CreateRequestParameters(
                commonParameters,
                requestContext);

            requestParams.LoginHint = interactiveParameters.LoginHint;

            var handler = new InteractiveRequest(
                ServiceBundle,
                requestParams,
                interactiveParameters,
                CreateWebAuthenticationDialog(interactiveParameters, requestParams.RequestContext));

            return(await handler.RunAsync(cancellationToken).ConfigureAwait(false));
        }