Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a simple bash script to download stream from Twitter:

curl -H "Authorization: ${TOKEN}" "$URL"

and I am looking for a way to generate the $TOKEN. I have all the input necessary (CONSUMER_KEY, ...), but where can I get the program oauth_sign that will generate the token from the input data?

share|improve this question
acme.com/software/oauth_sign – goldilocks Sep 15 '13 at 13:23
If you want a more elaborate example there is this: bentasker.co.uk/documentation/20-developmentprogramming/… – slm Sep 15 '13 at 13:25
up vote 5 down vote accepted

I just downloaded the link @goldilocks provided, http://acme.com/software/oauth_sign/, and confirmed that it compiles. Looks very straightfoward.


$ make
gcc -c -Wall -O liboauthsign.c
liboauthsign.c: In function ‘oauth_sign’:
liboauthsign.c:123:5: warning: implicit declaration of function ‘getpid’
liboauthsign.c:305:5: warning: pointer targets in passing argument 4 of ‘HMAC’ differ in signedness
/usr/include/openssl/hmac.h:99:16: note: expected ‘const unsigned char *’ but argument is of type ‘char *’
rm -f liboauthsign.a
ar rc liboauthsign.a liboauthsign.o
ranlib liboauthsign.a
gcc -Wall -O oauth_sign.c -L. -loauthsign -lcrypto -o oauth_sign


$ ./oauth_sign --help
usage:  oauth_sign [-q] consumer_key consumer_key_secret token token_secret method url [name=value ...]

excerpt from README

To use it, you supply the four cryptographic cookies and the method and URL of the request. If it's a POST request with extra parameters, you have to give those too. Oauth_sign puts all this together and makes the signature string. The signature is generated using HMAC-SHA1 as specified in RFC section 3.4.2, and is returned as an Authorization header value as specified in RFC section 3.5.1. This header can then be used in an HTTP request via, for example, the -h flag in http_get(1) and http_post(1) or the -H flag in curl(1).

Looks like it comes with a library exposing the fuctions for use in your own C applications as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.