Created
November 21, 2012 01:11
-
-
Save scottheckel/4122415 to your computer and use it in GitHub Desktop.
Yahoo API OAuth with OOB and Hammock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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