Tuesday, May 22, 2012

Setting up Twitter OAuth without 3rd party libraries

Continuation from Get twitter public timeline, json+C#, no 3rd party libraries



I'm still new to C# and oAuth so please bear with me if I fail to understand anything



I've created a C# class named oAuthClass, and these are the variables I currently have:



    static class oAuthClass
{
public static void run()
{
int oauth_timestamp = GetTimestamp(DateTime.Now);
string oauth_nonce = PseudoRandomStringUsingGUID();
string oauth_consumer_key = "consumer key here";
string oauth_signature_method = "HMAC-SHA1";
string oauth_version = "1.0";
}
}


I've read up on OAuth Signatures, and I chose to use HMAC-SHA1 for now, I don't know how to generate the signature, I'm also extremely confused after reading and seeing stuff like HTTP-Encodings and Base-Strings and whatnot (I've no idea what they mean at all), but my guess is to create a URL that's "Http-encoded", like spaces->"%20"?



In summary:
-What are base-strings?



-Am I right on the spaces->%20 example?



-HMAC-SHA1 involves a message and a key, is the consumer secret the message? Is the consumer key the key then?



-How to create a signature through the use of the HMAC-SHA1 algorithm



-If I do manage to create the signature, how do I pass these values to Twitter?



I could use



http://example.com?consumer_key=asdf&oauth_signature=signaturevalue&etc., 


but I've read and apparantly people use HTTP-Headers or something (again, I don't really know what this is)



Thank you! Again, no 3rd party libraries allowed :(





No comments:

Post a Comment