OAuthLib: OAuth1 and OAuth2 Implementation for Python
OAuthLib is a comprehensive, spec-compliant implementation of OAuth1 and OAuth2 request-signing logic for Python 3.8 and above. The current version is 3.3.1, released on March 27, 2026, with a regular release cadence for ongoing improvements and security updates.
Warnings
- breaking OAuthLib 3.0.0 introduced API-breaking changes, including the removal of 'request' from 'confirm_redirect_uri'.
- gotcha Ensure that 'requests' is installed when using OAuthLib, as it is commonly used for making HTTP requests in Python applications.
Install
-
pip install oauthlib
Imports
- OAuth1Session
from oauthlib.oauth1 import OAuth1Session
Quickstart
import os
from oauthlib.oauth1 import OAuth1Session
# Set up OAuth1Session with your credentials
oauth = OAuth1Session(client_key=os.environ.get('CLIENT_KEY'), client_secret=os.environ.get('CLIENT_SECRET'))
# Make a request to a protected resource
response = oauth.get('https://api.example.com/protected')
print(response.content)