cURL vers Python 2.7 pour raspberry
Bonjour,
J'ai beau essayer de codifier en python, je n'arrice pas à traduire cette demande Token pour l'API Myfox en Python...
Pouvez vous m'aider ?
Ligne à traduire en cURL :
curl https://api.myfox.me/oauth2/token -d 'grant_type=password&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&username=YOUR_USERNAME&password=YOUR_PASSWORD'
Ci-dessous la codification que j'ai faite en Python. A chaque fois j'ai un retour 400 (Bad request)
Citation:
import requests
url = "https://api.myfox.me/oauth2/token"
querystring = {"grant_type":"password"}
payload = "client_id=%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F&client_secret=%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F&username=%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F&password=%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F"
headers = {
'content-type': "application/x-www-form-urlencoded",
'cache-control': "no-cache",
'postman-token': "98f18521-fdad-eb8e-7e20-83e30c777404"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
PS : Biensur les informations client_id, client_secret,etc.. sont mises normalement,sans ?