Skip to content

Commit ae643ac

Browse files
committed
Added more docs on using the client.
1 parent 90b817a commit ae643ac

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This code was originally forked from [Leah Culver and Andy Smith's oauth.py code
1111
# Signing a Request
1212

1313
<pre><code>
14-
import oauth
14+
import oauth2 as oauth
1515
import time
1616

1717
# Set the API endpoint
@@ -44,3 +44,26 @@ req = oauth.Request(method="GET", url=url, parameters=params)
4444
signature_method = oauth.SignatureMethod_HMAC_SHA1()
4545
req.sign_request(signature_method, consumer, token)
4646
</code></pre>
47+
48+
# Using the Client
49+
50+
The <code>oauth2.Client</code> is based on <code>httplib2</code> and works just as you'd expect it to. The only difference is the first two arguments to the constructor are an instance of <code>oauth2.Consumer</code> and <code>oauth2.Token</code> (<code>oauth2.Token</code> is only needed for three-legged requests).
51+
52+
<pre><code>
53+
import oauth2 as oauth
54+
55+
# Create your consumer with the proper key/secret.
56+
consumer = oauth.Consumer(key="your-twitter-consumer-key",
57+
secret="your-twitter-consumer-secret")
58+
59+
# Request token URL for Twitter.
60+
request_token_url = "http://twitter.com/oauth/request_token"
61+
62+
# Create our client.
63+
client = oauth.Client(consumer)
64+
65+
# The OAuth Client request works just like httplib2 for the most part.
66+
resp, content = client.request(request_token_url, "GET")
67+
print resp
68+
print content
69+
</code></pre>

0 commit comments

Comments
 (0)