public static string FormatAuthUrl( string loginUrl, ResponseTypes responseType, string clientId, string redirectUrl, DisplayTypes display = DisplayTypes.Page, bool immediate = false, string state = "", string scope = "") { if (string.IsNullOrEmpty(loginUrl)) throw new ArgumentNullException("loginUrl"); if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException("clientId"); if (string.IsNullOrEmpty(redirectUrl)) throw new ArgumentNullException("redirectUrl"); //TODO: check ensure that redirectUrl is a valid URI var url = string.Format( "{0}?response_type={1}&client_id={2}&redirect_uri={3}&display={4}&immediate={5}&state={6}&scope={7}", loginUrl, responseType.ToString().ToLower(), clientId, redirectUrl, display.ToString().ToLower(), immediate, state, scope); return url; }
public static string FormatAuthUrl( string loginUrl, ResponseTypes responseType, string clientId, string redirectUrl, DisplayTypes display = DisplayTypes.Page, bool immediate = false, string scope = "") { if (string.IsNullOrEmpty(loginUrl)) { throw new ArgumentNullException("loginUrl"); } if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(redirectUrl)) { throw new ArgumentNullException("redirectUrl"); } var url = string.Format( "{0}?response_type={1}&client_id={2}&redirect_uri={3}&display={4}&immediate={5}&scope={6}", loginUrl, responseType.ToString().ToLower(), clientId, redirectUrl, display.ToString().ToLower(), immediate, scope); return(url); }
public static string FormatAuthUrl( string loginUrl, ResponseTypes responseType, string clientId, string redirectUrl, DisplayTypes display = DisplayTypes.Page, bool immediate = false, string state = "", string scope = "") { if (string.IsNullOrEmpty(loginUrl)) { throw new ArgumentNullException(nameof(loginUrl)); } if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException(nameof(clientId)); } if (string.IsNullOrEmpty(redirectUrl)) { throw new ArgumentNullException(nameof(redirectUrl)); } return ($"{loginUrl}?response_type={responseType.ToString().ToLower()}" + $"&client_id={clientId}" + $"&redirect_uri={redirectUrl}" + $"&display={display.ToString().ToLower()}" + $"&immediate={immediate}" + $"&state={state}" + $"&scope={scope}"); }
public TelemetryForm( IServiceProvider serviceProvider, ILog log, iRacingTelemetryOptions options, DisplayTypes displayType) : this() { FormDisplayInfo.DisplayType = displayType; FormDisplayInfo.Name = displayType.ToString(); _serviceProvider = (serviceProvider == null) ? throw new ArgumentNullException(nameof(serviceProvider)) : serviceProvider; Log = (log == null) ? throw new ArgumentNullException(nameof(log)) : log; Options = (options == null) ? throw new ArgumentNullException(nameof(options)) : options; }
//TODO: parser for redirect url result /// <summary> /// Formats an authentication URL for the Web Server Authentication Flow /// </summary> /// <param name="loginUrl">Required. Salesforce authorization endpoint.</param> /// <param name="clientId">Required. The Consumer Key from the connected app definition.</param> /// <param name="redirectUrl">Required. The Callback URL from the connected app definition.</param> /// <param name="display">Changes the login page’s display type</param> /// <param name="immediate">Determines whether the user should be prompted for login and approval. Default is false.</param> /// <param name="scope">OAuth scope - specifies what data your application can access</param> /// <param name="state">Specifies any additional URL-encoded state data to be returned in the callback URL after approval.</param> public static Uri WebServerAuthenticationUrl( string loginUrl, string clientId, string redirectUrl, DisplayTypes display = DisplayTypes.Page, bool immediate = false, string scope = "", string state = "" ) { if (string.IsNullOrEmpty(loginUrl)) { throw new ArgumentNullException("loginUrl"); } if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(redirectUrl)) { throw new ArgumentNullException("redirectUrl"); } //TODO: code_challenge, login_hint, nonce, prompt params const ResponseTypes responseType = ResponseTypes.Code; Dictionary <string, string> prms = new Dictionary <string, string>(); prms.Add("response_type", responseType.ToString().ToLower()); prms.Add("client_id", clientId); prms.Add("redirect_uri", redirectUrl); prms.Add("display", display.ToString().ToLower()); prms.Add("immediate", immediate.ToString().ToLower()); if (!string.IsNullOrEmpty(scope)) { prms.Add("scope", scope); } if (!string.IsNullOrEmpty(state)) { prms.Add("state", state); } string url = QueryHelpers.AddQueryString(loginUrl, prms); return(new Uri(url)); }
/// <summary> /// Formats an authentication URL for the User-Agent OAuth Authentication Flow /// </summary> /// <param name="loginUrl">(Required) Salesforce authorization endpoint.</param> /// <param name="clientId">(Required) The Consumer Key from the connected app definition.</param> /// <param name="redirectUrl">(Required) The Callback URL from the connected app definition.</param> /// <param name="display">Changes the login page’s display type</param> /// <param name="scope">OAuth scope - specifies what data your application can access</param> /// <param name="state">Specifies any additional URL-encoded state data to be returned in the callback URL after approval.</param> public static Uri UserAgentAuthenticationUrl( string loginUrl, string clientId, string redirectUrl, DisplayTypes display = DisplayTypes.Page, string state = "", string scope = "") { if (string.IsNullOrEmpty(loginUrl)) { throw new ArgumentNullException("loginUrl"); } if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException("clientId"); } if (string.IsNullOrEmpty(redirectUrl)) { throw new ArgumentNullException("redirectUrl"); } const ResponseTypes responseType = ResponseTypes.Token; Dictionary <string, string> prms = new Dictionary <string, string>(); prms.Add("response_type", responseType.ToString().ToLower()); prms.Add("client_id", clientId); prms.Add("redirect_uri", redirectUrl); prms.Add("display", display.ToString().ToLower()); if (!string.IsNullOrEmpty(scope)) { prms.Add("scope", scope); } if (!string.IsNullOrEmpty(state)) { prms.Add("state", state); } string url = QueryHelpers.AddQueryString(loginUrl, prms); return(new Uri(url)); }