我正在尝试使用以下 python 代码获取令牌(显示出现错误的位置):
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import BackendApplicationClient
client_id = 'my_id'
client_secret = 'my_secret'
encoded = 'WVkZjhjYTdkMDlkOjNhNWFjMTQzMmI4NjVlYWMyMDQ2' # Base64 Encoder
url = 'https://openapigw.tase.co.il/tase/prod/oauth/oauth2/token'
client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)
headers = {
'Authorization': 'Basic {}'.format(encoded),
'Content-Type': 'application/x-www-form-urlencoded'
}
body = {
'grant_type': 'client_credentials',
'scope': 'tase'
}
token = oauth.fetch_token(token_url=url, headers=headers, body=body)
我按照服务提供商的说明使用标题和正文。运行代码我得到以下错误 -
AttributeError:“dict”对象没有属性“decode”
该错误是指正文“dict”。有人可以帮忙吗?