/// <summary> /// Initializes a new instance of the <see cref="OAuthBase"/> class. /// </summary> /// <param name="authorizeUrl">The address for login.</param> /// <param name="accessTokenUrl">The address for the access token.</param> /// <param name="applicationId">The application identifier obtained from the provider website.</param> /// <param name="applicationSecret">The application secret key obtained from the provider website.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="authorizeUrl"/> is <b>null</b> or <b>empty</b>.</para> /// <para>-or-</para> /// <para><paramref name="accessTokenUrl"/> is <b>null</b> or <b>empty</b>.</para> /// <para>-or-</para> /// <para><paramref name="applicationId"/> is <b>null</b> or <b>empty</b>.</para> /// <para>-or-</para> /// <para><paramref name="applicationSecret"/> is <b>null</b> or <b>empty</b>.</para> /// </exception> public OAuthBase(string authorizeUrl, string accessTokenUrl, string applicationId, string applicationSecret) { if (String.IsNullOrEmpty(authorizeUrl)) { throw new ArgumentNullException("authorizeUrl"); } if (String.IsNullOrEmpty(accessTokenUrl)) { throw new ArgumentNullException("accessTokenUrl"); } if (String.IsNullOrEmpty(applicationId)) { throw new ArgumentNullException("applicationId"); } if (String.IsNullOrEmpty(applicationSecret)) { throw new ArgumentNullException("applicationSecret"); } this.AuthorizeUrl = authorizeUrl; this.AccessTokenUrl = accessTokenUrl; this.ApplicationId = applicationId; this.ApplicationSecret = applicationSecret; // set unique identifier to the instance this.State = OAuthUtility.GetRandomKey(); // add the instance to the clients collection OAuthManager.AddRequet(this.State, this); }
/// <summary> /// Creates a shallow copy of the current object. /// </summary> /// <returns>A shallow copy of the current object.</returns> /// <remarks> /// <para>Method creates a copy of the current object, removes tokens, change the return address, query parameters and state.</para> /// <para>Unfortunately, I made a mistake in architecture, so I had to make this method.</para> /// </remarks> /// <seealso cref="Clone(NameValueCollection, string)"/> public object Clone() { OAuthBase result = this.MemberwiseClone() as OAuthBase; result.State = OAuthUtility.GetRandomKey(); result.AccessToken = null; result.AuthorizationCode = null; if (result.GetType().IsSubclassOf(typeof(OAuthClient))) { ((OAuthClient)result).RequestToken = null; } OAuthManager.AddRequet(result.State, result); return(result); }