Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

TOKEN=$(oauth_sign $CONSUMER_KEY $CONSUMER_SECRET $ACCESS_TOKEN $ACCESS_SECRET GET $URL)
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

1 Answer 1

up vote 4 down vote accepted

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

compile

$ 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

usage

$ ./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

 
discard

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.