Reputation: 175
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
Upvotes: 1
Views: 4085
Reputation: 433
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.
Upvotes: 1