Reputation: 1137
New to OAuth and RestSharp.
I'm building a Windows Phone app, using RestSharp to handle all the OAuth stuff.
private void LoginButton_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
RestClient client = new RestClient(OAuth.Auth.baseurl);
client.Authenticator = RestSharp.Authenticators.OAuth1Authenticator.ForRequestToken(OAuth.Auth.consumerkey, OAuth.Auth.consumersecret);
var request = new RestRequest("oauth/request_token", Method.POST);
client.ExecuteAsync(request, (response) =>
{
var resource = response.Content;
MessageBox.Show(resource);
webBrowser1.Navigate(new Uri(OAuth.Auth.UAuthorise + "?" + resource + "&oauth_callback=http://bing.com"));
});
}
private void webBrowser1_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
MessageBox.Show(e.Uri.ToString() + " loaded");
}
I'm successfully getting the request token, and then a user is able to log in to the service. webBrowser1 then navigates to bing.com (as defined in the callback url). My question is: what do I do to get the oauth_token and oauth_token_secret? I can see them, due to the webBrowser1_LoadCompleted event handler, but how can I extract them to use them in my program?
Upvotes: 2
Views: 750
Reputation: 65566
Handle the Navigating
event for the browser control when it redirect back to the callback domain/Uri.
You can then extract the values you're after from from the Uri.
Upvotes: 2