OAuth 1 Authentication

A common form of authentication for several web APIs is OAuth. The requests-oauthlib library allows Requests users to easily make OAuth authenticated requests:

  1. >>> import requests
  2. >>> from requests_oauthlib import OAuth1
  3. >>> url = 'https://api.twitter.com/1.1/account/verify_credentials.json'
  4. >>> auth = OAuth1('YOUR_APP_KEY', 'YOUR_APP_SECRET',
  5. 'USER_OAUTH_TOKEN', 'USER_OAUTH_TOKEN_SECRET')
  6. >>> requests.get(url, auth=auth)
  7. <Response [200]>

For more information on how to OAuth flow works, please see the official OAuth website. For examples and documentation on requests-oauthlib, please see the requests_oauthlib repository on GitHub