/// <summary> /// Gets a request token from the provider. After acquiring a request token, the user should be redirected /// to the website of the provider for approving the application. If successful, the user will be redirected /// back to the specified callback URL where you then can exchange the request token for an access token. /// </summary> /// <returns>An instance of <see cref="OAuthRequestTokenResponse"/> representing the response.</returns> public virtual OAuthRequestTokenResponse GetRequestToken() { // Make the call to the API/provider IHttpResponse response = GetRequestTokenResponse(); // Parse the response body OAuthRequestToken body = OAuthRequestToken.Parse(this, response.Body); // Parse the response return(OAuthRequestTokenResponse.ParseResponse(response, body)); }
/// <summary> /// Gets a request token from the provider. After acquiring a request token, the user should be redirected /// to the website of the provider for approving the application. If successful, the user will be redirected /// back to the specified callback URL where you then can exchange the request token for an access token. /// </summary> /// <returns>An instance of <see cref="OAuthRequestTokenResponse"/> representing the response.</returns> public override OAuthRequestTokenResponse GetRequestToken() { // Flickr apparently deviates from the OAuth 1.0a specification, since they require the OAuth properties to // be specified in the query string. // Some error checking if (RequestTokenUrl == null) { throw new PropertyNotSetException("RequestTokenUrl"); } if (AuthorizeUrl == null) { throw new PropertyNotSetException("AuthorizeUrl"); } if (ConsumerKey == null) { throw new PropertyNotSetException("ConsumerKey"); } if (ConsumerSecret == null) { throw new PropertyNotSetException("ConsumerSecret"); } if (Callback == null) { throw new PropertyNotSetException("Callback"); } // Generate the OAuth signature string signature = GenerateSignature(HttpMethod.Get, RequestTokenUrl, default(IHttpQueryString), null); // Append the OAuth properties to the query string HttpQueryString queryString = new HttpQueryString { { "oauth_nonce", Nonce }, { "oauth_timestamp", Timestamp }, { "oauth_consumer_key", ConsumerKey }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_version", "1.0" }, { "oauth_signature", signature }, { "oauth_callback", Callback } }; // Make the call to the API IHttpResponse response = HttpUtils.Requests.Get(RequestTokenUrl, queryString); // Validate the response FlickrResponse.ValidateResponse(response); // Parse the response body OAuthRequestToken body = OAuthRequestToken.Parse(this, response.Body); // Parse the response return(OAuthRequestTokenResponse.ParseResponse(response, body)); }