401 error at request_token using out of band callback


#1

Hi all.

I am currently developping a desktop application. The OAuth part is based on the tweetsharp library.

I reach to get a request with the following header :

OAuth oauth_callback="oob", 
oauth_consumer_key="5uE0bYrzlifFJ8isgNUA",
oauth_nonce="E7cvlSBNCCxtOzReYQLM6Lcws", 
oauth_signature_method="HMAC-SHA1", 
oauth_timestamp="15321.23:28:37.3149036",
 oauth_signature="rvV7LUwyhh7zNwT4Y8r9zeyLakE%3D",
 oauth_version="1.0"

But it gets a 401 error. It may be related to the signature construction so here is the code for it :

            var sigBaseString = method + "&" + Globals.ProperUrlEscape(baseAddress) + "&" + Globals.ProperUrlEscape(string.Format(parameters, consumerKey, nonce, oAuthSignatureMethod, timestamp));
            

            string oAuthSignature;

            using (var sha = new HMACSHA1(Encoding.ASCII.GetBytes(consumerSecret + "&")))
            {
                oAuthSignature = Convert.ToBase64String(sha.ComputeHash(Encoding.ASCII.GetBytes(sigBaseString)));
            }

any help ?


#2

What format is that timestamp in? You’ll need to use a Unix timestamp, not whatever stardate that’s supposed to be :slight_smile:

When generating the base string, make sure to include all parameters, including query string parameters, and all oauth_* parameters (excepting oauth_signature). I don’t see oauth_version or oauth_callback being used in your base string, for example.

If you get a specific error message in addition to the 401, posting that will help debug.