Created
May 2, 2012 22:50
-
-
Save idan/2581132 to your computer and use it in GitHub Desktop.
Requests + OAuth, sample usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import OAuth1 | |
url = u'https://api.twitter.com/1/account/settings.json' | |
client_key = u'...' | |
client_secret = u'...' | |
resource_owner_key = u'...' | |
resource_owner_secret = u'...' | |
queryoauth = OAuth1(client_key, client_secret, | |
resource_owner_key, resource_owner_secret, | |
signature_type='query') | |
headeroauth = OAuth1(client_key, client_secret, | |
resource_owner_key, resource_owner_secret, | |
signature_type='auth_header') | |
bodyoauth = OAuth1(client_key, client_secret, | |
resource_owner_key, resource_owner_secret, | |
signature_type='body') | |
r_query = requests.get(url, auth=queryoauth) | |
r_header = requests.get(url, auth=headeroauth) | |
r_body = requests.post(url, auth=bodyoauth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment