Skip to content

Instantly share code, notes, and snippets.

@scottheckel
Created November 21, 2012 01:11
Show Gist options
  • Save scottheckel/4122415 to your computer and use it in GitHub Desktop.
Save scottheckel/4122415 to your computer and use it in GitHub Desktop.
Yahoo API OAuth with OOB and Hammock
using Hammock;
using Hammock.Authentication.OAuth;
var credentials = new OAuthCredentials
{
ConsumerKey = "[INSERTKEY]",
SignatureMethod = OAuthSignatureMethod.HmacSha1,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
ConsumerSecret = "[INSERTSECRET]",
CallbackUrl = "oob"
};
var client = new RestClient
{
Authority = "https://api.login.yahoo.com/oauth",
Credentials = credentials
};
client.BeginRequest(
new RestRequest
{
Path = "/v2/get_request_token"
},
(request, response, userState) =>
{
// Parse the query string either using System.Web or Whatever Means Available
// There are numerous examples of this online with various levels of correctness
var queryParameters = ParseQueryString(response.Content);
oAuthToken = queryParameters["oauth_token"];
oAuthTokenSecret = queryParameters["oauth_token_secret"];
var authorizeUrl = "https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=" + oAuthToken;
// TODO: Insert logic to navigate to this URL in a browser window
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment