JavaScript
x
6
1
curl -v POST https://api-m.sandbox.paypal.com/v1/oauth2/token
2
-H "Accept: application/json"
3
-H "Accept-Language: en_US"
4
-u "CLIENT_ID:SECRET"
5
-d "grant_type=client_credentials"
6
This piece of code is from the api documentation. I can’t figure out how to perform this action in python. Please help me to complete this query using python.
Advertisement
Answer
A simple translation:
JavaScript
1
12
12
1
resp = requests.post(
2
url="https://api-m.sandbox.paypal.com/v1/oauth2/token",
3
auth=("CLIENT_ID", "SECRET"),
4
data=b"grant_type=client_credentials",
5
headers={
6
"Accept": "application/json",
7
"Accept-Language": "en_US",
8
},
9
)
10
resp.raise_for_status()
11
print(resp.json())
12