pip install oauthlib
python
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import BackendApplicationClient
python
client_id = 'your_client_id'
client_secret = 'your_client_secret'
python
client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)
python
token = oauth.fetch_token(token_url='https://example.com/token',
client_id=client_id,
client_secret=client_secret)