Signature


#1

Hello all.
Completly new to OAuth.

I have implemented a class in Java with this method
string signature = Signature.calculateRFC2104HMAC(data, key);

I tried Signature,calculateRFC2104HMAC ([consumerkey], [secrete key])
But still geting 401 status code when u call request token.

What i have no clue is what should i set in data and key parameters.

I would apretiate any help.

Thank you very much.


#2

Data is the signature base string. Key is the signing key, composed of the consumer secret and token secret.

Obtaining both of these values is described here: https://dev.twitter.com/docs/auth/creating-signature

My advice would be that unless you’re willing to put up with a lot of frustration until you get your signing completely correct, you should use a third party oauth library. Twitter4j happens to be excellent: http://twitter4j.org/en/index.html


#3

Hi. Thanks for your response @kurrik

I am still geting 401 status code.

This is the base string of a tipical request: POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_consumer_key%3Dv3d7b9dlaTuGxx9OuEuPoA%26oauth_nonce%3DkijzVNLOY0ZFaKJqWbFfYz3uAPQ2pTgcZeNu2XD4cg%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1332811430%26oauth_version%3D1.0

This is the “Authorization:” header i am sending.
oauth_consumer_key=“v3d7b9dlaTuGx…oA”,oauth_nonce=“kijz…XD4cg”,oauth_signature=“66a…EX71+VefGGFM=”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1332811430”,oauth_version=“1.0”

Any idea
Thanks.


#4

PS: Of course the method is POST. Actually not sending anything in the content.


#5

By the way… I am trying to get it correct but also following your advice.


#6

Your signature is not percent encoded. Make sure you follow the steps at the bottom of https://dev.twitter.com/docs/auth/authorizing-request precisely.


#7

Hi @kurrik I figured out Twitter4J and seems to work fine. I think thats the path i will take :slight_smile:

Thanks for your support.