Python OAuth2 Example Code Needs Update

oauth
python

#1

The example Python code listed at https://dev.twitter.com/oauth/overview/single-user does not work with the OAuth2 library. The correct code is this:

def oauth_req(url, key, secret, http_method="GET", post_body=””, http_headers=None):
    consumer = oauth2.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
    token = oauth2.Token(key=key, secret=secret)
    client = oauth2.Client(consumer, token)
    resp, content = client.request( url, method=http_method, body=post_body, headers=http_headers )
    return content

home_timeline = oauth_req( 'https://api.twitter.com/1.1/statuses/home_timeline.json', 'abcdefg', 'hijklmnop' )

#2

Thanks for the report - I’ve updated the docs!


#3