/// <summary> /// Creates an authorization url that can be used to authorize access to a user's account. /// </summary> /// <param name="oAuth2ResponseType">Determines if Imgur returns a Code, a PIN code, or an opaque Token.</param> /// <param name="state"> /// This optional parameter indicates any state which may be useful to your application upon receipt of /// the response. /// </param> /// <returns></returns> public string GetAuthorizationUrl(OAuth2ResponseType oAuth2ResponseType, string state) { var url = $"{AuthorizationEndpointUrl}?client_id={ApiClient.ClientId}&response_type={oAuth2ResponseType}&state={state}"; return(url); }
/// <summary> /// Creates an authorization url that can be used to authorize access to a user's account. /// </summary> /// <param name="oAuth2ResponseType">Determines if Imgur returns a Code, a PIN code, or an opaque Token.</param> /// <param name="state"> /// This optional parameter indicates any state which may be useful to your application upon receipt of /// the response. /// </param> /// <returns></returns> public string GetAuthorizationUrl(OAuth2ResponseType oAuth2ResponseType, string state = null) { var responseType = oAuth2ResponseType.ToString().ToLowerInvariant(); var url = $"{AuthorizationEndpointUrl}?client_id={ApiClient.ClientId}&response_type={responseType}&state={state}"; return url; }
/// <summary> /// Creates an authorization url that can be used to authorize access to a user's account. /// </summary> /// <param name="oAuth2ResponseType">Determines if Imgur returns a Code, a PIN code, or an opaque Token.</param> /// <param name="state"> /// This optional parameter indicates any state which may be useful to your application upon receipt of /// the response. /// </param> /// <returns></returns> public string GetAuthorizationUrl(OAuth2ResponseType oAuth2ResponseType, string state = null) { var responseType = oAuth2ResponseType.ToString().ToLowerInvariant(); var url = $"{AuthorizationEndpointUrl}?client_id={ApiClient.ClientId}&response_type={responseType}&state={state}"; return(url); }
public String GetAuthorizeUrl(OAuth2ResponseType responseType, IDictionary <String, String> queryString) { var url = this.GetAuthorizeUrl(responseType); Func <String, String> f = UrlEncode; StringBuilder sb = new StringBuilder(); foreach (var key in queryString.Keys) { sb.AppendFormat("&{0}={1}", f(key), f(queryString[key])); } return(url + sb.ToString()); }
internal static string ConvertResponseTypeToString(OAuth2ResponseType value) { switch (value) { case OAuth2ResponseType.Code: return(RESPONSE_TYPE_CODE); case OAuth2ResponseType.Token: return(RESPONSE_TYPE_TOKEN); default: return(null); } }
public override string GetAuthorizeUrl(OAuth2ResponseType responseType) { return(String.Format("https://api.vimeo.com/oauth/authorize?response_type=code&client_id={0}&redirect_uri={1}" , this.ClientID, WebUtility.UrlEncode(this.RedirectUrl))); }
protected string BuildAuthorizationUrl(string endPoint, string redirectUrl, string scope = "", OAuth2ResponseType responseType = OAuth2ResponseType.Code, string state = "", IEnumerable <KeyValuePair <string, string> > parameters = null) { UrlBuilder request = new UrlBuilder(endPoint); request.QueryString.Add(RestConstants.OAuth2ResponseType, responseType.ToDescription()); request.QueryString.Add(RestConstants.OAuth2ClientID, this.AppID); request.QueryString.Add(RestConstants.OAuth2RedirectUri, redirectUrl); if (!string.IsNullOrWhiteSpace(scope)) { request.QueryString.Add(RestConstants.OAuth2Scope, scope); } if (!string.IsNullOrWhiteSpace(state)) { request.QueryString.Add(RestConstants.OAuth2State, state); } if (parameters != null) { foreach (var parameter in parameters.Where(parameter => !string.IsNullOrWhiteSpace(parameter.Value))) { request.QueryString.Add(parameter.Key, parameter.Value); } } var buildAuthorizationUrl = request.ToString(this.UrlEncode); return(buildAuthorizationUrl); }
public abstract String GetAuthorizeUrl(OAuth2ResponseType responseType);
/// <summary> /// Creates an authorization url that can be used to authorize access to a user's account. /// </summary> /// <param name="oAuth2ResponseType">Determines if Imgur returns a Code, a PIN code, or an opaque Token.</param> /// <param name="state"> /// This optional parameter indicates any state which may be useful to your application upon receipt of /// the response. /// </param> /// <returns></returns> public string GetAuthorizationUrl(OAuth2ResponseType oAuth2ResponseType, string state = null) { return(string.Format("{0}?client_id={1}&response_type={2}&state={3}", (object)this.AuthorizationEndpointUrl, (object)this.ApiClient.ClientId, (object)oAuth2ResponseType.ToString().ToLowerInvariant(), (object)state)); }
public String GetAuthorizeUrl(OAuth2ResponseType responseType, IDictionary<String, String> queryString) { var url = this.GetAuthorizeUrl(responseType); Func<String, String> f = UrlEncode; StringBuilder sb = new StringBuilder(); foreach (var key in queryString.Keys) { sb.AppendFormat("&{0}={1}", f(key), f(queryString[key])); } return url + sb.ToString(); }
public Uri GetAuthorizationUri( OAuth2ResponseType responseType = OAuth2ResponseType.Token, FacebookPermission[] requestPermissions = null) { AuthorizationResponseType = responseType; var responseTypeString = "f**k"; switch (responseType) { case OAuth2ResponseType.Token: responseTypeString = "token"; break; case OAuth2ResponseType.Code: responseTypeString = "token"; break; case OAuth2ResponseType.CodeAndToken: responseTypeString = "code%20token"; break; } if (requestPermissions == null) { requestPermissions = new[] { FacebookPermission.BasicInfo }; } else if (!requestPermissions.Contains(FacebookPermission.BasicInfo)) { var requestPermissionsTemp = new FacebookPermission[requestPermissions.Length + 1]; requestPermissionsTemp[0] = FacebookPermission.BasicInfo; requestPermissions.CopyTo(requestPermissionsTemp, 1); requestPermissions = requestPermissionsTemp; } var scopeStringBuilder = new StringBuilder(); foreach (var permission in requestPermissions) { var permissionString = permission.CamelCaseToUnderlineString(); if (permissionString.StartsWith("user_actions")) { permissionString = permissionString.Remove(12, 1); permissionString = permissionString.Insert(12, "."); } else if (permissionString.StartsWith("friends_actions")) { permissionString = permissionString.Remove(15, 1); permissionString = permissionString.Insert(15, "."); } scopeStringBuilder.Append(permissionString); scopeStringBuilder.Append(','); } return (new Uri( string.Format( "{0}?client_id={1}&redirect_uri={2}&response_type={3}&scope={4}&display=popup", ClientUris.AuthorizationResource, ConsumerCredentials.Key, Uri.EscapeDataString( ClientUris.CallbackRequestTokenUri == null ? "https://www.facebook.com/connect/login_success.html" : ClientUris.CallbackRequestTokenUri.AbsoluteUri), responseTypeString, scopeStringBuilder.ToString().Remove(scopeStringBuilder.Length - 1)))); }