4 This project provides first-class OAuth library support for `Requests <http://python-requests.org>`_.
9 OAuth 1 can seem overly complicated and it sure has its quirks. Luckily,
10 requests_oauthlib hides most of these and let you focus at the task at hand.
12 Accessing protected resources using requests_oauthlib is as simple as:
16 >>> from requests_oauthlib import OAuth1Session
17 >>> twitter = OAuth1Session('client_key',
18 client_secret='client_secret',
19 resource_owner_key='resource_owner_key',
20 resource_owner_secret='resource_owner_secret')
21 >>> url = 'https://api.twitter.com/1/account/settings.json'
22 >>> r = twitter.get(url)
24 Before accessing resources you will need to obtain a few credentials from your
25 provider (i.e. Twitter) and authorization from the user for whom you wish to
26 retrieve resources for. You can read all about this in the full
27 `OAuth 1 workflow guide on RTD <http://requests-oauthlib.readthedocs.org/en/latest/oauth1_workflow.html>`_.
32 OAuth 2 is generally simpler than OAuth 1 but comes in more flavours. The most
33 common being the Authorization Code Grant, also known as the WebApplication
36 Fetching a protected resource after obtaining an access token can be as simple as:
40 >>> from requests_oauthlib import OAuth2Session
41 >>> google = OAuth2Session(r'client_id', token=r'token')
42 >>> url = 'https://www.googleapis.com/oauth2/v1/userinfo'
43 >>> r = google.get(url)
45 Before accessing resources you will need to obtain a few credentials from your
46 provider (i.e. Google) and authorization from the user for whom you wish to
47 retrieve resources for. You can read all about this in the full
48 `OAuth 2 workflow guide on RTD <http://requests-oauthlib.readthedocs.org/en/latest/oauth2_workflow.html>`_.
53 To install requests and requests_oauthlib you can use pip:
57 $ pip install requests requests_oauthlib