Python OAuth2 Example Code Needs Update



The example Python code listed at 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( '', 'abcdefg', 'hijklmnop' )


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