README.rst 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Requests-OAuthlib |build-status| |coverage-status| |docs|
  2. =========================================================
  3. This project provides first-class OAuth library support for `Requests <https://requests.readthedocs.io>`_.
  4. The OAuth 1 workflow
  5. --------------------
  6. OAuth 1 can seem overly complicated and it sure has its quirks. Luckily,
  7. requests_oauthlib hides most of these and let you focus at the task at hand.
  8. Accessing protected resources using requests_oauthlib is as simple as:
  9. .. code-block:: pycon
  10. >>> from requests_oauthlib import OAuth1Session
  11. >>> twitter = OAuth1Session('client_key',
  12. client_secret='client_secret',
  13. resource_owner_key='resource_owner_key',
  14. resource_owner_secret='resource_owner_secret')
  15. >>> url = 'https://api.twitter.com/1/account/settings.json'
  16. >>> r = twitter.get(url)
  17. Before accessing resources you will need to obtain a few credentials from your
  18. provider (e.g. Twitter) and authorization from the user for whom you wish to
  19. retrieve resources for. You can read all about this in the full
  20. `OAuth 1 workflow guide on RTD <https://requests-oauthlib.readthedocs.io/en/latest/oauth1_workflow.html>`_.
  21. The OAuth 2 workflow
  22. --------------------
  23. OAuth 2 is generally simpler than OAuth 1 but comes in more flavours. The most
  24. common being the Authorization Code Grant, also known as the WebApplication
  25. flow.
  26. Fetching a protected resource after obtaining an access token can be extremely
  27. simple. However, before accessing resources you will need to obtain a few
  28. credentials from your provider (e.g. Google) and authorization from the user
  29. for whom you wish to retrieve resources for. You can read all about this in the
  30. full `OAuth 2 workflow guide on RTD <https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html>`_.
  31. Installation
  32. -------------
  33. To install requests and requests_oauthlib you can use pip:
  34. .. code-block:: bash
  35. pip install requests requests-oauthlib
  36. .. |build-status| image:: https://github.com/requests/requests-oauthlib/actions/workflows/run-tests.yml/badge.svg
  37. :target: https://github.com/requests/requests-oauthlib/actions
  38. .. |coverage-status| image:: https://img.shields.io/coveralls/requests/requests-oauthlib.svg
  39. :target: https://coveralls.io/r/requests/requests-oauthlib
  40. .. |docs| image:: https://readthedocs.org/projects/requests-oauthlib/badge/
  41. :alt: Documentation Status
  42. :scale: 100%
  43. :target: https://requests-oauthlib.readthedocs.io/