1
votes

I run this code

from oauthlib.oauth2 import BackendApplicationClient

from requests.auth import HTTPBasicAuth

import oauth2

import oauth

tokens_url = "https://x123.com/oauth/token"

client = BackendApplicationClient(client_id=client_id)

oauth = OAuth2Session(client=client)

token = oauth.fetch_token(token_url=tokens_url, client_id=client_id,

client_secret=client_secret)

and I get NameError: name 'OAuth2Session' is not defined

1

1 Answers

1
votes

Try:

from requests_oauthlib import OAuth2Session

You may need to install requests_oauthlib using pip if it hasn't already been installed on your system.