public static string CreateAuthorizeUrl(this AuthorizeRequest request, string clientId, string responseType, string scope = null, string redirectUri = null, string state = null, string nonce = null, string loginHint = null, string acrValues = null, string responseMode = null, object extra = null) { var values = new Dictionary <string, string> { { OAuth2Constants.ClientId, clientId }, { OAuth2Constants.ResponseType, responseType } }; if (!string.IsNullOrWhiteSpace(scope)) { values.Add(OAuth2Constants.Scope, scope); } if (!string.IsNullOrWhiteSpace(redirectUri)) { values.Add(OAuth2Constants.RedirectUri, redirectUri); } if (!string.IsNullOrWhiteSpace(state)) { values.Add(OAuth2Constants.State, state); } if (!string.IsNullOrWhiteSpace(nonce)) { values.Add(OAuth2Constants.Nonce, nonce); } if (!string.IsNullOrWhiteSpace(loginHint)) { values.Add(OAuth2Constants.LoginHint, loginHint); } if (!string.IsNullOrWhiteSpace(acrValues)) { values.Add(OAuth2Constants.AcrValues, acrValues); } if (!string.IsNullOrWhiteSpace(responseMode)) { values.Add(OAuth2Constants.ResponseMode, responseMode); } return(request.Create(Merge(values, ObjectToDictionary(extra)))); }
/// <summary>Creates the authorize URL.</summary> /// <param name="request">The request.</param> /// <param name="values">The values (either using a string Dictionary or an object's properties).</param> /// <returns></returns> public static string Create(this AuthorizeRequest request, object values) { return(request.Create(ObjectToDictionary(values))); }
public void StartFlow(string responseType, string scope) { // create URI to authorize endpoint - use WebHost or SelfHost from the // samples solution. var authorizeRequest = new AuthorizeRequest("https://localhost:44333/core/connect/authorize"); // dictionary with values for the authorize request var dic = new Dictionary<string, string>(); dic.Add("client_id", "implicitclient"); dic.Add("response_type", responseType); dic.Add("scope", scope); dic.Add("redirect_uri", "https://xamarin-oidc-sample/redirect"); dic.Add("nonce", Guid.NewGuid().ToString("N")); // add CSRF token to protect against cross-site request forgery attacks. _currentCSRFToken = Guid.NewGuid().ToString("N"); dic.Add("state", _currentCSRFToken); var authorizeUri = authorizeRequest.Create(dic); // or use CreateAuthorizeUrl, passing in the values we defined in the dictionary. // authorizeRequest.CreateAuthorizeUrl("implicitclient", ...); wvLogin.Source = authorizeUri; wvLogin.IsVisible = true; }
public void StartFlow(string responseType, string scope) { // create URI to auth endpoint var authorizeRequest = new AuthorizeRequest("https://xamarinoidcsamplests.azurewebsites.net/identity/connect/authorize"); // note: change URI to wherever you deployed your STS (CTRL-SHIFT-F is your friend :)). // For use with IIS Express, check https://www.github.com/KevinDockx/XamarinFormsOIDCSample. // dictionary with values for the authorize request var dic = new Dictionary<string, string>(); dic.Add("client_id", "xamarinsampleimplicit"); dic.Add("response_type", responseType); dic.Add("scope", scope); dic.Add("redirect_uri", "https://xamarin-oidc-sample/redirect"); dic.Add("nonce", Guid.NewGuid().ToString("N")); // add CSRF token to protect against cross-site request forgery attacks. _currentCSRFToken = Guid.NewGuid().ToString("N"); dic.Add("state", _currentCSRFToken); var authorizeUri = authorizeRequest.Create(dic); // or use CreateAuthorizeUrl, passing in the values we defined in the dictionary. // authorizeRequest.CreateAuthorizeUrl("xamarinsampleimplicit", ...); wvLogin.Source = authorizeUri; wvLogin.IsVisible = true; }