使用 python 个请求创建请求(从另一种语言翻译成 python)
create request with python requests (translation from another language to python)
curl -v POST https://api-m.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "CLIENT_ID:SECRET" \
-d "grant_type=client_credentials"
这段代码来自api文档。我不知道如何在 python 中执行此操作。请帮助我使用 python.
完成此查询
一个简单的翻译:
resp = requests.post(
url="https://api-m.sandbox.paypal.com/v1/oauth2/token",
auth=("CLIENT_ID", "SECRET"),
data=b"grant_type=client_credentials",
headers={
"Accept": "application/json",
"Accept-Language": "en_US",
},
)
resp.raise_for_status()
print(resp.json())
curl -v POST https://api-m.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "CLIENT_ID:SECRET" \
-d "grant_type=client_credentials"
这段代码来自api文档。我不知道如何在 python 中执行此操作。请帮助我使用 python.
完成此查询一个简单的翻译:
resp = requests.post(
url="https://api-m.sandbox.paypal.com/v1/oauth2/token",
auth=("CLIENT_ID", "SECRET"),
data=b"grant_type=client_credentials",
headers={
"Accept": "application/json",
"Accept-Language": "en_US",
},
)
resp.raise_for_status()
print(resp.json())