pip install rauth
python
from rauth import OAuth2Service
oauth_service = OAuth2Service(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
access_token_url='https://example.com/oauth/access_token',
authorize_url='https://example.com/oauth/authorize',
base_url='https://example.com/api/'
)
authorize_url = oauth_service.get_authorize_url()
print(authorize_url)
session = oauth_service.get_auth_session(data={'code': authorization_code,
'grant_type': 'authorization_code'})
response = session.get('https://example.com/api/resource')
print(response.json())