【发布时间】:2021-09-17 11:41:38
【问题描述】:
对于一个项目,我尝试使用请求模块在 Python 中获取访问令牌。
它适用于 GET 方法:
import requests, json
# Oauth API - GET call - Winnie project
access_token = requests.get("https://api.ebanking.com/oauth/access_token?grant_type=client_credentials&client_id=27c5b286-62a6-45c7-beda-abbaea6eecf2&client_secret=6731de76-14a6-49ae-97bc-6eba6914391e").json()["access_token"]
但是,不能使用 POST 方法:
import requests, json
data = {'grant_type':'client_credentials',
'client_id':'27c5b286-62a6-45c7-beda-abbaea6eecf2',
'client_secret':'6731de76-14a6-49ae-97bc-6eba6914391e'}
# Oauth API - POST call - Winnie project
access_token = requests.post(url = "https://api.ebanking.dev/oauth", data = data).json()["access_token"]
有什么想法吗?
【问题讨论】:
-
欢迎来到 Stack Overflow!请使用tour,阅读主题here、How to Ask 和question checklist,并提供minimal reproducible example。
标签: python