/// <summary> /// Registers the specified client in the application. /// </summary> /// <param name="providerName">The provider name.</param> /// <param name="clientId">The application identifier obtained from the provider website.</param> /// <param name="clientSecret">The application secret key obtained from the provider website.</param> /// <param name="scope">List of scope that will be requested from the provider. Only for OAuth 2.0.</param> /// <param name="initArgs">Additional parameters to be passed to the constructor of the client class.</param> /// <param name="parameters">Additional parameters that will be transferred to the provider website.</param> /// <exception cref="ArgumentNullException"><paramref name="providerName"/>, <paramref name="clientId"/> or <paramref name="clientSecret"/> is <b>null</b> or <b>empty</b>.</exception> /// <exception cref="UnknownProviderException">Provider not found by <paramref name="providerName"/>.</exception> /// <exception cref="NotSupportedException">The <paramref name="providerName"/> not suppored <paramref name="scope"/>.</exception> /// <example> /// <code lang="C#"> /// OAuthManager.RegisterClient /// ( /// "google", /// "1058655871432-83b9micke7cll89jfmcno5nftha3e95o.apps.googleusercontent.com", /// "AeEbEGQqoKgOZb41JUVLvEJL" /// ); /// /// OAuthManager.RegisterClient /// ( /// "facebook" /// "1435890426686808", /// "c6057dfae399beee9e8dc46a4182e8fd" /// ); /// </code> /// <code lang="VB"> /// OAuthManager.RegisterClient _ /// ( /// "google", /// "1058655871432-83b9micke7cll89jfmcno5nftha3e95o.apps.googleusercontent.com", /// "AeEbEGQqoKgOZb41JUVLvEJL" /// ) /// /// OAuthManager.RegisterClient _ /// ( /// "facebook", /// "1435890426686808", /// "c6057dfae399beee9e8dc46a4182e8fd" /// ) /// </code> /// </example> public static void RegisterClient(string providerName, string clientId, string clientSecret, string scope = null, NameValueCollection parameters = null, object[] initArgs = null) { OAuthManager.RegisterClient(ClientName.Parse(providerName), clientId, clientSecret, scope, parameters, initArgs); }
/// <summary> /// Returns the authorization URL of the specified provider, query parameters and return URL. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <param name="parameters">Additional parameters to be passed to the authorization URL.</param> /// <param name="returnUrl">The address to which the user is redirected after the authorization.</param> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> public static string GetAuthorizationUrl(string clientName, NameValueCollection parameters, string returnUrl) { return(OAuthWeb.GetAuthorizationUrl(ClientName.Parse(clientName), parameters, returnUrl, null)); }
/// <summary> /// Registers the specified client in the application. /// </summary> /// <param name="providerName">The provider name.</param> /// <param name="clientId">The application identifier obtained from the provider website.</param> /// <param name="clientSecret">The application secret key obtained from the provider website.</param> /// <exception cref="ArgumentNullException"><paramref name="providerName"/>, <paramref name="clientId"/> or <paramref name="clientSecret"/> is <b>null</b> or <b>empty</b>.</exception> /// <exception cref="UnknownProviderException">Provider not found by <paramref name="providerName"/>.</exception> /// <example> /// <code lang="C#"> /// OAuthManager.RegisterClient /// ( /// "google", /// "1058655871432-83b9micke7cll89jfmcno5nftha3e95o.apps.googleusercontent.com", /// "AeEbEGQqoKgOZb41JUVLvEJL" /// ); /// /// OAuthManager.RegisterClient /// ( /// "facebook" /// "1435890426686808", /// "c6057dfae399beee9e8dc46a4182e8fd" /// ); /// </code> /// <code lang="VB"> /// OAuthManager.RegisterClient _ /// ( /// "google", /// "1058655871432-83b9micke7cll89jfmcno5nftha3e95o.apps.googleusercontent.com", /// "AeEbEGQqoKgOZb41JUVLvEJL" /// ) /// /// OAuthManager.RegisterClient _ /// ( /// "facebook", /// "1435890426686808", /// "c6057dfae399beee9e8dc46a4182e8fd" /// ) /// </code> /// </example> public static void RegisterClient(string providerName, string clientId, string clientSecret) { OAuthManager.RegisterClient(ClientName.Parse(providerName), clientId, clientSecret, null, null, null); }
/// <summary> /// Returns the authorization URL of the specified provider and return URL. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <param name="returnUrl">The address to which the user is redirected after the authorization.</param> /// <param name="state">Custom state associated with authorization request.</param> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> public static string GetAuthorizationUrl(string clientName, string returnUrl, object state) { return(OAuthWeb.GetAuthorizationUrl(ClientName.Parse(clientName), null, returnUrl, state)); }
/// <summary> /// Returns the authorization URL of the specified provider. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> public static string GetAuthorizationUrl(string clientName) { return(OAuthWeb.GetAuthorizationUrl(ClientName.Parse(clientName), null, null, null)); }
/// <summary> /// Redirects current client to the authorization page of the specified provider, query parameters and return URL. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <param name="returnUrl">The address to which the user is redirected after the authorization.</param> /// <param name="parameters">Additional parameters to be passed to the authorization query.</param> /// <exception cref="ClientIsNotRegisteredException"> /// <paramref name="clientName"/> is unregistered. Use the <see cref="OAuthManager.RegisterClient(OAuthBase)" /> for OAuth clients registration. /// </exception> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> /// <remarks> /// <para>The method will not work in desktop applications. For desktop applications you can use <see cref="GetAuthorizationUrl(string, NameValueCollection, string)"/>.</para> /// </remarks> /// <seealso cref="GetAuthorizationUrl(string, NameValueCollection, string)"/> public static void RedirectToAuthorization(string clientName, NameValueCollection parameters, string returnUrl) { OAuthWeb.RedirectToAuthorization(ClientName.Parse(clientName), parameters, returnUrl, null); }
/// <summary> /// Redirects current client to the authorization page of the specified provider and return URL. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <param name="returnUrl">The address to which the user is redirected after the authorization.</param> /// <param name="state">Custom state associated with authorization request.</param> /// <exception cref="ClientIsNotRegisteredException"> /// <paramref name="clientName"/> is unregistered. Use the <see cref="OAuthManager.RegisterClient(OAuthBase)" /> for OAuth clients registration. /// </exception> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> /// <remarks> /// <para>The method will not work in desktop applications. For desktop applications you can use <see cref="GetAuthorizationUrl(string, string)"/>.</para> /// </remarks> /// <seealso cref="GetAuthorizationUrl(string, string, object)"/> public static void RedirectToAuthorization(string clientName, string returnUrl, object state) { OAuthWeb.RedirectToAuthorization(ClientName.Parse(clientName), null, returnUrl, state); }
/// <summary> /// Redirects current client to the authorization page of the specified provider. /// </summary> /// <param name="clientName">Provider name, through which it is necessary to authorize the current user.</param> /// <exception cref="ClientIsNotRegisteredException"> /// <paramref name="clientName"/> is unregistered. Use the <see cref="OAuthManager.RegisterClient(OAuthBase)" /> for OAuth clients registration. /// </exception> /// <exception cref="NullHttpContextException"> /// The exception that is thrown when you try to access methods that are designed for web projects. /// </exception> /// <remarks> /// <para>The method will not work in desktop applications. For desktop applications you can use <see cref="GetAuthorizationUrl(string)"/>.</para> /// </remarks> /// <seealso cref="GetAuthorizationUrl(string)"/> public static void RedirectToAuthorization(string clientName) { OAuthWeb.RedirectToAuthorization(ClientName.Parse(clientName), null, null, null); }