2010年1月23日 星期六

How to use OAuth Test Client

result of using OAuth in Python

OAuth in JaiKu

http://www.jaiku.com/api/docs/authentication

where you need to use custom key and custom secret first from following URL:


(get your account in Jaiku first).

then you can use customer key, and secret, with the endpoint and got following oauth_token and oauth_token_secret to use "oauth Test client" (http://term.ie/oauth/example/client.php)


oauth_token_secret=c9255a1ac98e4d2c994f1bea9f126ddc&oauth_token=c197c65ff203448fa102c8f3ee3b07e5




Python code to use OAuth get Jaiku actor info

import urllib2 from oauth import oauth consumer = oauth.OAuthConsumer('79f64f084f9043a9a1a2a5a026c71e77', '09b14b79f8bc46e39da369892a68c6a9') access_token = oauth.OAuthToken('c197c65ff203448fa102c8f3ee3b07e5', 'c9255a1ac98e4d2c994f1bea9f126ddc') parameters = {'nick': 'mingderwang', 'method': 'actor_get'} request = oauth.OAuthRequest.from_consumer_and_token( oauth_consumer=consumer, token=access_token, http_url='http://api.jaiku.com/json', http_method='POST', parameters=parameters) request.sign_request( oauth.OAuthSignatureMethod_HMAC_SHA1(), consumer, access_token) result = urllib2.urlopen(urllib2.Request( 'http://api.jaiku.com/json', request.to_postdata())) print result.read() result.close()

Whoa! That was *not* what I was expecting.