public override string ToString() { var sb = new StringBuilder("RequestTokenResponse("); bool __first = true; if (RequestToken != null && __isset.requestToken) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("RequestToken: "); RequestToken.ToString(sb); } if (ReturnUrl != null && __isset.returnUrl) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ReturnUrl: "); ReturnUrl.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
/// <summary> /// IRequest interface implementation /// </summary> /// <param name="uiParams"></param> public override void AppendItemsTo(Dictionary <string, string> uiParams) { if (uiParams == null) { return; } base.AppendItemsTo(uiParams); if (!String.IsNullOrEmpty(InstanceId)) { uiParams.Add("instance_id", InstanceId); } if (RequestToken) { uiParams.Add("request_token", RequestToken.ToString()); } if (!String.IsNullOrEmpty(MoneySourceToken)) { uiParams.Add("money_source_token", MoneySourceToken); } }
/// <summary> /// Create a request token from the request. /// </summary> /// <param name="rawUri">A System.Uri object containing information regarding the URL of the current request.</param> /// <param name="queryString">The collection of HTTP query string variables.</param> /// <param name="form">The collection of form variables.</param> /// <param name="headers">The collection of HTTP headers.</param> /// <param name="cookies">The collection of cookies sent by the client.</param> /// <returns>The token if successful; else null.</returns> public string CreateRequestToken(Uri rawUri, NameValueCollection queryString, NameValueCollection form, NameValueCollection headers, HttpCookieCollection cookies) { try { // Make sure that all the passed parameters are valid. if (rawUri == null) { throw new ArgumentNullException("rawUri"); } if (queryString == null) { throw new ArgumentNullException("queryString"); } if (form == null) { throw new ArgumentNullException("form"); } if (headers == null) { throw new ArgumentNullException("headers"); } if (cookies == null) { throw new ArgumentNullException("cookies"); } // Make sure that all the maditory OAuth parameters // have been passed to the provider from the consumer OAuthProblemReport validate = new OAuthProblemReport(queryString); validate.ValidateRequestParametersAbsent(queryString); string validationError = validate.ToString(); // If any of the maditory OAuth parameters are missing. if (!String.IsNullOrEmpty(validationError)) { throw new OAuthException(OAuthProblemParameters.ParameterAbsent, "Absent Parameters", new Exception(validationError)); } // Create an assign each manditory parameter. IOAuthContext context = new OAuthContextProvider(); context.RawUri = rawUri; context.RequestMethod = "GET"; context.Headers = headers; context.QueryParameters = queryString; context.FormEncodedParameters = form; context.CallbackUrl = queryString[Parameters.OAuth_Callback]; context.Nonce = queryString[Parameters.OAuth_Nonce]; context.ConsumerKey = queryString[Parameters.OAuth_Consumer_Key]; context.SignatureMethod = queryString[Parameters.OAuth_Signature_Method]; context.Timestamp = queryString[Parameters.OAuth_Timestamp]; context.Signature = queryString[Parameters.OAuth_Signature]; // Assign each optional parameter GetOptionalRequestParameters(context, queryString); // Create the request token from the stores. IToken token = _oAuthProvider.GrantRequestToken(context); RequestToken requestToken = new RequestToken() { Token = token.Token, TokenSecret = token.TokenSecret, ConsumerKey = token.ConsumerKey, CallbackUrl = context.CallbackUrl, SessionHandle = token.SessionHandle, Realm = token.Realm }; // Return the request token string. return(requestToken.ToString()); } catch (OAuthException aex) { // Get the current token errors. _tokenError = aex.Report.ToString(); return(null); } catch (Exception ex) { // Transform the execption. OAuthException OAuthException = new OAuthException(OAuthProblemParameters.ParameterRejected, ex.Message, ex); // Get the current token errors. _tokenError = OAuthException.Report.ToString(); return(null); } }