ignore the __pychache__ directory
[yelp-api-cdsw] / docs / requests-oauthlib-README.rst
1 Requests-OAuthlib
2 =================
3
4 This project provides first-class OAuth library support for `Requests <http://python-requests.org>`_.
5
6 The OAuth 1 workflow
7 --------------------
8
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.
11
12 Accessing protected resources using requests_oauthlib is as simple as:
13
14 .. code-block:: pycon
15
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)
23
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>`_.
28
29 The OAuth 2 workflow
30 --------------------
31
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
34 flow.
35
36 Fetching a protected resource after obtaining an access token can be as simple as:
37
38 .. code-block:: pycon
39
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)
44
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>`_.
49
50 Installation
51 -------------
52
53 To install requests and requests_oauthlib you can use pip:
54
55 .. code-block:: bash
56
57     $ pip install requests requests_oauthlib

Benjamin Mako Hill || Want to submit a patch?