OAuth authentication for a desktop Twitter client?
June 29, 2009 7:09 AM   RSS feed for this thread Subscribe

I'm working on a Twitter client that I intend to eventually post to Projects, but I've hit a stumbling block with OAuth authentication.

I'm using the excellent Twitter OAuth implementation from Shannon Whitley. My application can successfully get an Authorization Link, and Twitter gives me a six-digit PIN. I'm having a devil of a time getting that PIN back to Twitter for the final authentication step.

I added the following method to Shannon's OAuth class:
public bool ValidatePin(string PIN)
{
string response = WebRequest(Method.GET, string.Format("{0}?oauth_verifier={1}", ACCESS_TOKEN, PIN), string.Empty);
if (response.Length > 0)
{
//Store the Token and Token Secret
var qs = HttpUtility.ParseQueryString(response);
if (!string.IsNullOrEmpty(qs["oauth_token"])) this.Token = qs["oauth_token"];
if (!string.IsNullOrEmpty(qs["oauth_token_secret"])) this.TokenSecret = qs["oauth_token_secret"];
return true;
}
else
{
return false;
}
}

I consistently get "401-Unauthorized" from Twitter when making the "oauth_verifier" call.

I know that my application's consumer_key and consumer_key_secret are valid, because I can successfully get the authorization link with the PIN.

I've been over the OAuth documentation and the Twitter API Wiki and haven't been able to turn up a solution.

Any help or guidance on this would be greatly appreciated, and I'll compose adoring haiku about you and include it in the code that I'll be releasing open-source.
posted by DWRoelands to computers & internet (2 comments total)
I hope you don't mind a stab in the dark: Are you sure that the PIN you're passing to ValidatePIN is clean, without extra whitespace and what not? Can you try making that parameter an int and making the format string argument {1:d} to ensure that a number is being passed?
posted by ignignokt at 7:21 AM on June 29


I don't mind at all. I know that the input's clean, but your suggestion is a good piece of defensive programming that 'll definitely add.
posted by DWRoelands at 8:22 AM on June 29


« Older What is the high quality, econ...   |   Is there any way to cannibaliz... Newer »

You are not logged in, either login or create an account to post comments