private string CreateDeviceCodeRequestUriString()
        {
            var deviceCodeRequestParameters = new DictionaryRequestParameters(this.resource, this.clientKey);

            if (this.callState != null && this.callState.CorrelationId != Guid.Empty)
            {
                deviceCodeRequestParameters[OAuthParameter.CorrelationId] = this.callState.CorrelationId.ToString();
            }

            IDictionary <string, string> adalIdParameters = AdalIdHelper.GetAdalIdParameters();

            foreach (KeyValuePair <string, string> kvp in adalIdParameters)
            {
                deviceCodeRequestParameters[kvp.Key] = kvp.Value;
            }

            if (!string.IsNullOrWhiteSpace(extraQueryParameters))
            {
                // Checks for extraQueryParameters duplicating standard parameters
                Dictionary <string, string> kvps = EncodingHelper.ParseKeyValueList(extraQueryParameters, '&', false, this.callState);
                foreach (KeyValuePair <string, string> kvp in kvps)
                {
                    if (deviceCodeRequestParameters.ContainsKey(kvp.Key))
                    {
                        throw new AdalException(AdalError.DuplicateQueryParameter, string.Format(CultureInfo.CurrentCulture, AdalErrorMessage.DuplicateQueryParameterTemplate, kvp.Key));
                    }
                }

                deviceCodeRequestParameters.ExtraQueryParameter = extraQueryParameters;
            }

            return(new Uri(new Uri(this.authenticator.DeviceCodeUri), "?" + deviceCodeRequestParameters).AbsoluteUri);
        }
        public void RequestParametersTest()
        {
            const string ClientId = "client_id";
            const string AdditionalParameter = "additional_parameter";
            const string AdditionalParameter2 = "additional_parameter2";
            string expectedString = string.Format("client_id=client_id&{0}={1}&{2}={3}", AdditionalParameter, EncodingHelper.UrlEncode(ComplexString), AdditionalParameter2, EncodingHelper.UrlEncode(ComplexString2));

            var param = new DictionaryRequestParameters(null, new ClientKey(ClientId));
            param[AdditionalParameter] = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Verify.AreEqual(expectedString, param.ToString());

            param = new DictionaryRequestParameters(null, new ClientKey(ClientId));
            param[AdditionalParameter] = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Verify.AreEqual(expectedString, param.ToString());

            param = new DictionaryRequestParameters(null, new ClientKey(ClientId));
            param[AdditionalParameter] = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Verify.AreEqual(expectedString, param.ToString());

            var stringParam = new StringRequestParameters(new StringBuilder(expectedString));
            Verify.AreEqual(expectedString, stringParam.ToString());
        }
        public void RequestParametersTest()
        {
            const string ClientId             = "client_id";
            const string AdditionalParameter  = "additional_parameter";
            const string AdditionalParameter2 = "additional_parameter2";
            string       expectedString       = string.Format(CultureInfo.CurrentCulture, "client_id=client_id&{0}={1}&{2}={3}", AdditionalParameter, EncodingHelper.UrlEncode(ComplexString), AdditionalParameter2, EncodingHelper.UrlEncode(ComplexString2));

            var param = new DictionaryRequestParameters(null, new ClientKey(ClientId));

            param[AdditionalParameter]  = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Assert.AreEqual(expectedString, param.ToString());

            param = new DictionaryRequestParameters(null, new ClientKey(ClientId));
            param[AdditionalParameter]  = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Assert.AreEqual(expectedString, param.ToString());

            param = new DictionaryRequestParameters(null, new ClientKey(ClientId));
            param[AdditionalParameter]  = ComplexString;
            param[AdditionalParameter2] = ComplexString2;
            Assert.AreEqual(expectedString, param.ToString());

            var stringParam = new StringRequestParameters(new StringBuilder(expectedString));

            Assert.AreEqual(expectedString, stringParam.ToString());
        }
        public static void AdalIdTest()
        {
            IHttpClient request = PlatformPlugin.HttpClientFactory.Create("https://test", null);
            var adalParameters = AdalIdHelper.GetAdalIdParameters();

            Verify.AreEqual(4, adalParameters.Count);
            Verify.IsNotNull(adalParameters[AdalIdParameter.Product]);
            Verify.IsNotNull(adalParameters[AdalIdParameter.Version]);
            Verify.IsNotNull(adalParameters[AdalIdParameter.CpuPlatform]);
#if TEST_ADAL_WINRT_UNIT
            Verify.IsFalse(adalParameters.ContainsKey(AdalIdParameter.OS));
            Verify.IsNotNull(adalParameters[AdalIdParameter.DeviceModel]);
#else
            Verify.IsNotNull(adalParameters[AdalIdParameter.OS]);
            Verify.IsFalse(adalParameters.ContainsKey(AdalIdParameter.DeviceModel));
#endif

            var parameters = new DictionaryRequestParameters(null, new ClientKey("client_id"));
            adalParameters = AdalIdHelper.GetAdalIdParameters();

            Verify.AreEqual(4, adalParameters.Count);
            Verify.IsNotNull(adalParameters[AdalIdParameter.Product]);
            Verify.IsNotNull(adalParameters[AdalIdParameter.Version]);
            Verify.IsNotNull(adalParameters[AdalIdParameter.CpuPlatform]);
#if TEST_ADAL_WINRT_UNIT
            Verify.IsFalse(adalParameters.ContainsKey(AdalIdParameter.OS));
            Verify.IsNotNull(adalParameters[AdalIdParameter.DeviceModel]);
#else
            Verify.IsNotNull(adalParameters[AdalIdParameter.OS]);
            Verify.IsFalse(adalParameters.ContainsKey(AdalIdParameter.DeviceModel));
#endif
        }
Example #5
0
        protected virtual async Task <AuthenticationResultEx> SendTokenRequestAsync()
        {
            var requestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);

            this.AddAditionalRequestParameters(requestParameters);
            return(await this.SendHttpMessageAsync(requestParameters).ConfigureAwait(false));
        }
Example #6
0
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     if (this.userAssertion != null)
     {
         requestParameters[OAuthParameter.GrantType] = this.userAssertion.AssertionType;
         requestParameters[OAuthParameter.Assertion] = Convert.ToBase64String(Encoding.UTF8.GetBytes(this.userAssertion.Assertion));
     }
 }
        protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
        {
            requestParameters[OAuthParameter.GrantType] = OAuthGrantType.JwtBearer;
            requestParameters[OAuthParameter.Assertion] = this.userAssertion.Assertion;
            requestParameters[OAuthParameter.RequestedTokenUse] = OAuthRequestedTokenUse.OnBehalfOf;

            // To request id_token in response
            requestParameters[OAuthParameter.Scope] = ADALScopeHelper.CreateSingleStringFromArray(Scope);
        }
        protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
        {
            requestParameters[OAuthParameter.GrantType] = OAuthGrantType.JwtBearer;
            requestParameters[OAuthParameter.Assertion] = this.userAssertion.Assertion;
            requestParameters[OAuthParameter.RequestedTokenUse] = OAuthRequestedTokenUse.OnBehalfOf;

            // To request id_token in response
            requestParameters[OAuthParameter.Scope] = OAuthValue.ScopeOpenId;
        }
Example #9
0
        protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
        {
            requestParameters[OAuthParameter.GrantType]         = OAuthGrantType.JwtBearer;
            requestParameters[OAuthParameter.Assertion]         = this.userAssertion.Assertion;
            requestParameters[OAuthParameter.RequestedTokenUse] = OAuthRequestedTokenUse.OnBehalfOf;

            //TODO To request id_token in response
            //requestParameters[OAuthParameter.Scope] = OAuthValue.ScopeOpenId;
        }
        private DictionaryRequestParameters CreateAuthorizationRequest(string loginHint)
        {
            var authorizationRequestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);

            authorizationRequestParameters[OAuthParameter.ResponseType] = OAuthResponseType.Code;
            authorizationRequestParameters[OAuthParameter.HasChrome]    = "1";
            authorizationRequestParameters[OAuthParameter.RedirectUri]  = this.redirectUriRequestParameter;

            if (!string.IsNullOrWhiteSpace(loginHint))
            {
                authorizationRequestParameters[OAuthParameter.LoginHint] = loginHint;
            }

            if (!string.IsNullOrWhiteSpace(claims))
            {
                authorizationRequestParameters["claims"] = claims;
            }

            if (this.CallState != null && this.CallState.CorrelationId != Guid.Empty)
            {
                authorizationRequestParameters[OAuthParameter.CorrelationId] = this.CallState.CorrelationId.ToString();
            }

            if (this.authorizationParameters != null)
            {
                platformInformation.AddPromptBehaviorQueryParameter(this.authorizationParameters, authorizationRequestParameters);
            }

            IDictionary <string, string> adalIdParameters = AdalIdHelper.GetAdalIdParameters();

            foreach (KeyValuePair <string, string> kvp in adalIdParameters)
            {
                authorizationRequestParameters[kvp.Key] = kvp.Value;
            }


            if (!string.IsNullOrWhiteSpace(extraQueryParameters))
            {
                // Checks for extraQueryParameters duplicating standard parameters
                Dictionary <string, string> kvps = EncodingHelper.ParseKeyValueList(extraQueryParameters, '&', false, this.CallState);
                foreach (KeyValuePair <string, string> kvp in kvps)
                {
                    if (authorizationRequestParameters.ContainsKey(kvp.Key))
                    {
                        throw new AdalException(AdalError.DuplicateQueryParameter, string.Format(CultureInfo.CurrentCulture, AdalErrorMessage.DuplicateQueryParameterTemplate, kvp.Key));
                    }
                }

                authorizationRequestParameters.ExtraQueryParameter = extraQueryParameters;
            }

            return(authorizationRequestParameters);
        }
Example #11
0
        private DictionaryRequestParameters CreateAuthorizationRequest(string loginHint)
        {
            HashSet <string> unionScope = this.GetDecoratedScope(new HashSet <string>(this.Scope.Union(this._additionalScope)));

            var authorizationRequestParameters = new DictionaryRequestParameters(unionScope, this.ClientKey);

            authorizationRequestParameters[OAuthParameter.ResponseType] = OAuthResponseType.Code;

            if (!string.IsNullOrWhiteSpace(this.Policy))
            {
                authorizationRequestParameters[OAuthParameter.Policy] = this.Policy;
            }

            authorizationRequestParameters[OAuthParameter.RedirectUri] = this._redirectUriRequestParameter;

            if (!string.IsNullOrWhiteSpace(loginHint))
            {
                authorizationRequestParameters[OAuthParameter.LoginHint] = loginHint;
            }

            if (this.CallState != null && this.CallState.CorrelationId != Guid.Empty)
            {
                authorizationRequestParameters[OAuthParameter.CorrelationId] = this.CallState.CorrelationId.ToString();
            }

            IDictionary <string, string> adalIdParameters = MsalIdHelper.GetMsalIdParameters();

            foreach (KeyValuePair <string, string> kvp in adalIdParameters)
            {
                authorizationRequestParameters[kvp.Key] = kvp.Value;
            }

            AddUiOptionToRequestParameters(authorizationRequestParameters);

            if (!string.IsNullOrWhiteSpace(_extraQueryParameters))
            {
                // Checks for _extraQueryParameters duplicating standard parameters
                Dictionary <string, string> kvps = EncodingHelper.ParseKeyValueList(_extraQueryParameters, '&', false, this.CallState);
                foreach (KeyValuePair <string, string> kvp in kvps)
                {
                    if (authorizationRequestParameters.ContainsKey(kvp.Key))
                    {
                        throw new MsalException(MsalError.DuplicateQueryParameter, string.Format(CultureInfo.InvariantCulture, MsalErrorMessage.DuplicateQueryParameterTemplate, kvp.Key));
                    }
                }

                authorizationRequestParameters.ExtraQueryParameter = _extraQueryParameters;
            }

            return(authorizationRequestParameters);
        }
        protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
        {
            if (this.userAssertion != null)
            {
                requestParameters[OAuthParameter.GrantType] = this.userAssertion.AssertionType;
                requestParameters[OAuthParameter.Assertion] = Convert.ToBase64String(Encoding.UTF8.GetBytes(this.userAssertion.Assertion));
            }
            else
            {
                this.userCredential.ApplyTo(requestParameters);
            }

            // To request id_token in response
            requestParameters[OAuthParameter.Scope] = OAuthValue.ScopeOpenId;
        }
        internal async Task <AuthenticationResultEx> SendTokenRequestByRefreshTokenAsync(string refreshToken)
        {
            var requestParameters = new DictionaryRequestParameters(this.GetDecoratedScope(this.Scope), this.ClientKey);

            requestParameters[OAuthParameter.GrantType]    = OAuthGrantType.RefreshToken;
            requestParameters[OAuthParameter.RefreshToken] = refreshToken;

            AuthenticationResultEx result = await this.SendHttpMessageAsync(requestParameters).ConfigureAwait(false);

            if (result.RefreshToken == null)
            {
                result.RefreshToken = refreshToken;
                PlatformPlugin.Logger.Information(this.CallState, "Refresh token was missing from the token refresh response, so the refresh token in the request is returned instead");
            }

            return(result);
        }
Example #14
0
        protected async Task <AuthenticationResultEx> SendTokenRequestByRefreshTokenAsync(string refreshToken)
        {
            var requestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);

            requestParameters[OAuthParameter.GrantType]    = OAuthGrantType.RefreshToken;
            requestParameters[OAuthParameter.RefreshToken] = refreshToken;
            requestParameters[OAuthParameter.Scope]        = OAuthValue.ScopeOpenId;

            AuthenticationResultEx result = await this.SendHttpMessageAsync(requestParameters).ConfigureAwait(false);

            if (result.RefreshToken == null)
            {
                result.RefreshToken = refreshToken;

                var msg = "Refresh token was missing from the token refresh response, so the refresh token in the request is returned instead";
                CallState.Logger.Verbose(this.CallState, msg);
                CallState.Logger.VerbosePii(this.CallState, msg);
            }

            return(result);
        }
Example #15
0
        private void AddUiOptionToRequestParameters(DictionaryRequestParameters authorizationRequestParameters)
        {
            switch (this._uiOptions)
            {
            case UiOptions.ForceConsent:
                authorizationRequestParameters[OAuthParameter.Prompt] = "consent";
                break;

            case UiOptions.ForceLogin:
                authorizationRequestParameters[OAuthParameter.Prompt] = "login";
                break;

            case UiOptions.SelectAccount:
                authorizationRequestParameters[OAuthParameter.Prompt] = "select_account";
                break;

            case UiOptions.ActAsCurrentUser:
                authorizationRequestParameters[OAuthParameter.RestrictToHint] = "true";
                break;
            }
        }
        protected async Task<AuthenticationResultEx> SendTokenRequestByRefreshTokenAsync(string refreshToken)
        {
            var requestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);
            requestParameters[OAuthParameter.GrantType] = OAuthGrantType.RefreshToken;
            requestParameters[OAuthParameter.RefreshToken] = refreshToken;
            AuthenticationResultEx result = await this.SendHttpMessageAsync(requestParameters);

            if (result.RefreshToken == null)
            {
                result.RefreshToken = refreshToken;
                PlatformPlugin.Logger.Verbose(this.CallState, "Refresh token was missing from the token refresh response, so the refresh token in the request is returned instead");
            }

            return result;
        }
 protected virtual async Task<AuthenticationResultEx> SendTokenRequestAsync()
 {
     var requestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);
     this.AddAditionalRequestParameters(requestParameters);
     return await this.SendHttpMessageAsync(requestParameters);
 }
 protected abstract void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters);
 internal virtual void ApplyTo(DictionaryRequestParameters requestParameters)
 {
 }
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     if (this.userAssertion != null)
     {
         requestParameters[OAuthParameter.GrantType] = this.userAssertion.AssertionType;
         requestParameters[OAuthParameter.Assertion] = Convert.ToBase64String(Encoding.UTF8.GetBytes(this.userAssertion.Assertion));
     }
 }
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType] = OAuthGrantType.DeviceCode;
     requestParameters[OAuthParameter.Code]      = this.deviceCodeResult.DeviceCode;
 }
        public override void AddPromptBehaviorQueryParameter(IPlatformParameters parameters, DictionaryRequestParameters authorizationRequestParameters)
        {
            PlatformParameters authorizationParameters = (parameters as PlatformParameters);

            if (authorizationParameters == null)
            {
                throw new ArgumentException("parameters should be of type PlatformParameters", "parameters");
            }

            PromptBehavior promptBehavior = authorizationParameters.PromptBehavior;

            switch (promptBehavior)
            {
            case PromptBehavior.Always:
                authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.Login;
                break;

            case PromptBehavior.SelectAccount:
                authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.SelectAccount;
                break;

            case PromptBehavior.RefreshSession:
                authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.RefreshSession;
                break;
            }
        }
Example #23
0
 protected abstract void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters);
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType] = OAuthGrantType.AuthorizationCode;
     requestParameters[OAuthParameter.Code] = this.authorizationResult.Code;
     requestParameters[OAuthParameter.RedirectUri] = this.redirectUriRequestParameter;
 }
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {            
 }
Example #26
0
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType]   = OAuthGrantType.AuthorizationCode;
     requestParameters[OAuthParameter.Code]        = this.authorizationCode;
     requestParameters[OAuthParameter.RedirectUri] = this.redirectUri.OriginalString;
 }
 public virtual void AddPromptBehaviorQueryParameter(IPlatformParameters parameters, DictionaryRequestParameters authorizationRequestParameters)
 {
     authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.Login;
 }
Example #28
0
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType]   = OAuthGrantType.AuthorizationCode;
     requestParameters[OAuthParameter.Code]        = this.authorizationResult.Code;
     requestParameters[OAuthParameter.RedirectUri] = this._redirectUriRequestParameter;
 }
        private DictionaryRequestParameters CreateAuthorizationRequest(string loginHint)
        {
            HashSet<string> unionScope = this.GetDecoratedScope(new HashSet<string>(this.Scope.Union(this._additionalScope)));

            var authorizationRequestParameters = new DictionaryRequestParameters(unionScope, this.ClientKey);
            authorizationRequestParameters[OAuthParameter.ResponseType] = OAuthResponseType.Code;

            if (!string.IsNullOrWhiteSpace(this.Policy))
            {
                authorizationRequestParameters[OAuthParameter.Policy] = this.Policy;
            }

            authorizationRequestParameters[OAuthParameter.RedirectUri] = this._redirectUriRequestParameter;

            if (!string.IsNullOrWhiteSpace(loginHint))
            {
                authorizationRequestParameters[OAuthParameter.LoginHint] = loginHint;
            }

            if (this.CallState != null && this.CallState.CorrelationId != Guid.Empty)
            {
                authorizationRequestParameters[OAuthParameter.CorrelationId] = this.CallState.CorrelationId.ToString();
            }
            
                IDictionary<string, string> adalIdParameters = MsalIdHelper.GetMsalIdParameters();
                foreach (KeyValuePair<string, string> kvp in adalIdParameters)
                {
                    authorizationRequestParameters[kvp.Key] = kvp.Value;
                }

            AddUiOptionToRequestParameters(authorizationRequestParameters);

            if (!string.IsNullOrWhiteSpace(_extraQueryParameters))
            {
                // Checks for _extraQueryParameters duplicating standard parameters
                Dictionary<string, string> kvps = EncodingHelper.ParseKeyValueList(_extraQueryParameters, '&', false, this.CallState);
                foreach (KeyValuePair<string, string> kvp in kvps)
                {
                    if (authorizationRequestParameters.ContainsKey(kvp.Key))
                    {
                        throw new MsalException(MsalError.DuplicateQueryParameter, string.Format(CultureInfo.InvariantCulture,MsalErrorMessage.DuplicateQueryParameterTemplate, kvp.Key));
                    }
                }

                authorizationRequestParameters.ExtraQueryParameter = _extraQueryParameters;
            }

            return authorizationRequestParameters;
        }
        public override void AddPromptBehaviorQueryParameter(IPlatformParameters parameters, DictionaryRequestParameters authorizationRequestParameters)
        {
            PlatformParameters authorizationParameters = (parameters as PlatformParameters);
            if (authorizationParameters == null)
            {
                throw new ArgumentException("parameters should be of type PlatformParameters", "parameters");
            }

            PromptBehavior promptBehavior = (parameters as PlatformParameters).PromptBehavior;

            // ADFS currently ignores the parameter for now.
            switch (promptBehavior)
            {
                case PromptBehavior.Always:
                    authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.Login;
                    break;
                case PromptBehavior.RefreshSession:
                    authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.RefreshSession;
                    break;
                case PromptBehavior.Never:
                    authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.AttemptNone;
                    break;
            }
        }
        private void AddUiOptionToRequestParameters(DictionaryRequestParameters authorizationRequestParameters)
        {
            switch (this._uiOptions)
            {
                case UiOptions.ForceConsent:
                    authorizationRequestParameters[OAuthParameter.Prompt]= "consent";
                    break;

                case UiOptions.ForceLogin:
                    authorizationRequestParameters[OAuthParameter.Prompt] = "login";
                    break;

                case UiOptions.SelectAccount:
                    authorizationRequestParameters[OAuthParameter.Prompt] = "select_account";
                    break;

                case UiOptions.ActAsCurrentUser:
                    authorizationRequestParameters[OAuthParameter.RestrictToHint] = "true";
                    break;
            }
            
        }
 protected virtual async Task<List<AuthenticationResultEx>> SendTokenRequestAsync()
 {
     var requestParameters = new DictionaryRequestParameters(this.GetDecoratedScope(this.Scope), this.ClientKey);
     var extraQueryParameters = this.AddAdditionalQueryStringParameters();
     this.AddAditionalRequestParameters(requestParameters);
     return await this.SendHttpMessageAsync(requestParameters, extraQueryParameters);
 }
        internal async Task<AuthenticationResultEx> SendTokenRequestByRefreshTokenAsync(string refreshToken)
        {
            var requestParameters = new DictionaryRequestParameters(this.GetDecoratedScope(this.Scope), this.ClientKey);
            requestParameters[OAuthParameter.GrantType] = OAuthGrantType.RefreshToken;
            requestParameters[OAuthParameter.RefreshToken] = refreshToken;

            AuthenticationResultEx result = await this.SendHttpMessageAsync(requestParameters).ConfigureAwait(false);

            if (result.RefreshToken == null)
            {
                result.RefreshToken = refreshToken;
                PlatformPlugin.Logger.Information(this.CallState, "Refresh token was missing from the token refresh response, so the refresh token in the request is returned instead");
            }

            return result;
        }
Example #34
0
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
 }
        protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
        {
            if (this.userAssertion != null)
            {
                requestParameters[OAuthParameter.GrantType] = this.userAssertion.AssertionType;
                requestParameters[OAuthParameter.Assertion] = Convert.ToBase64String(Encoding.UTF8.GetBytes(this.userAssertion.Assertion));
            }
            else
            {
                requestParameters[OAuthParameter.GrantType] = OAuthGrantType.Password;
                requestParameters[OAuthParameter.Username] = this.userCredential.UserName;
                requestParameters[OAuthParameter.Password] = this.userCredential.Password;
            }

            // To request id_token in response
            requestParameters[OAuthParameter.Scope] = OAuthValue.ScopeOpenId;
        }
 protected virtual async Task<AuthenticationResultEx> SendTokenRequestAsync()
 {
     var requestParameters = new DictionaryRequestParameters(this.GetDecoratedScope(this.Scope), this.ClientKey);
     this.AddAditionalRequestParameters(requestParameters);
     return await this.SendHttpMessageAsync(requestParameters).ConfigureAwait(false);
 }
        private DictionaryRequestParameters CreateAuthorizationRequest(string loginHint)
        {
            var authorizationRequestParameters = new DictionaryRequestParameters(this.Resource, this.ClientKey);
            authorizationRequestParameters[OAuthParameter.ResponseType] = OAuthResponseType.Code;

            authorizationRequestParameters[OAuthParameter.RedirectUri] = this.redirectUriRequestParameter;

            if (!string.IsNullOrWhiteSpace(loginHint))
            {
                authorizationRequestParameters[OAuthParameter.LoginHint] = loginHint;
            }

            if (this.CallState != null && this.CallState.CorrelationId != Guid.Empty)
            {
                authorizationRequestParameters[OAuthParameter.CorrelationId] = this.CallState.CorrelationId.ToString();
            }

            if (this.authorizationParameters != null)
            {
                PlatformPlugin.PlatformInformation.AddPromptBehaviorQueryParameter(this.authorizationParameters, authorizationRequestParameters);
            }

            if (PlatformPlugin.HttpClientFactory.AddAdditionalHeaders)
            {
                IDictionary<string, string> adalIdParameters = AdalIdHelper.GetAdalIdParameters();
                foreach (KeyValuePair<string, string> kvp in adalIdParameters)
                {
                    authorizationRequestParameters[kvp.Key] = kvp.Value;
                }
            }

            if (!string.IsNullOrWhiteSpace(extraQueryParameters))
            {
                // Checks for extraQueryParameters duplicating standard parameters
                Dictionary<string, string> kvps = EncodingHelper.ParseKeyValueList(extraQueryParameters, '&', false, this.CallState);
                foreach (KeyValuePair<string, string> kvp in kvps)
                {
                    if (authorizationRequestParameters.ContainsKey(kvp.Key))
                    {
                        throw new AdalException(AdalError.DuplicateQueryParameter, string.Format(AdalErrorMessage.DuplicateQueryParameterTemplate, kvp.Key));
                    }
                }

                authorizationRequestParameters.ExtraQueryParameter = extraQueryParameters;
            }

            return authorizationRequestParameters;
        }
 public virtual void AddPromptBehaviorQueryParameter(IPlatformParameters parameters, DictionaryRequestParameters authorizationRequestParameters)
 {
     authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.Login;
 }
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType] = OAuthGrantType.ClientCredentials;
 }
 public override void AddPromptBehaviorQueryParameter(IPlatformParameters parameters, DictionaryRequestParameters authorizationRequestParameters)
 {
     // Do not add prompt=login to the query to be able to use the mock dictionary created by Test.ADAL.NET.
 }            
 protected override void AddAditionalRequestParameters(DictionaryRequestParameters requestParameters)
 {
     requestParameters[OAuthParameter.GrantType] = OAuthGrantType.ClientCredentials;
 }
 public virtual void AddUiOptionsQueryParameter(UiOptions options, DictionaryRequestParameters authorizationRequestParameters)
 {
     authorizationRequestParameters[OAuthParameter.Prompt] = PromptValue.Login;
 }