我运行此代码
来自oauthlib.oauth2的导入BackendApplicationClient
来自requests.auth的导入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)
我得到NameError:名称'OAuth2Session'未定义
答案 0 :(得分:0)
尝试:
from requests_oauthlib import OAuth2Session
如果您的系统上尚未安装install requests_oauthlib using pip,则可能需要。