OAuth with C# Part II: Authorize and Access Token
Continuing from Part I we need to now allow the user to authorize the application to access their data and we need to obtain our access token. The user authorization is as simple as appending the oauthToken to the end of the access URL and opening a browser window:// go get authorized
string oauthURL = "http://www.goodreads.com/oauth/authorize?oauth_token=" + oauthToken;
// open a browser and allow the user to authorize
System.Diagnostics.Process.Start(oauthURL);
Once the user has verified that they have allowed your application access then you can obtain the access token and secret. This follows pretty much exactly from the Part I code except this time when generating the signature we want to pass in the OAuth token and OAuth token secret that we got in Part I.
uri = new Uri("http://www.goodreads.com/oauth/access_token");
nonce = oAuth.GenerateNonce();
timeStamp = oAuth.GenerateTimeStamp();
// this time we need our oauth token and oauth token secret
sig = oAuth.GenerateSignature(uri, consumerKey, consumerSecret, oauthToken, oauthTokenSecret, "GET", timeStamp, nonce, out normalizedUrl, out normalizedRequestParameters);
sig = HttpUtility.UrlEncode(sig);
// notice that the sig is always being appended to the end
string accessUrl = normalizedUrl + "?" + normalizedRequestParameters + "&oauth_signature=" + sig;
oauthTokenReq(accessUrl, out oauthToken, out oauthTokenSecret);
Console.WriteLine("ouathToken: " + oauthToken + "oauthTokenSecret:" + oauthTokenSecret);
Note that oauthTokenReq() is doing the same work of that ugly do while loop from Part I to grab the data from the page, but I decided to throw it into it's own method.




Ada Lovelace is considered the world's first computer programmer. In the world of computer science today it's almost astonishing that computer programming could have first been done by a woman. After all the percentage of woman in computing professions is somewhere around 20%. The reasons for this seem to be completely out of our grasp. It's been suggested that the “geek” stereotype is completely unappealing for women, but the number of female videogamers is around 38% and rising. Additionally, the percentage of female Star Trek fans is somewhere around 40% (which I think we can all agree is far geekier than programming).