ForumsDevelopersAlways get "The grant type was not specified in the request"
Always get "The grant type was not specified in the request"
Author | Message |
---|---|
ishayahu |
I try to get access_token & refresh_token after getting auth_code. As it states in documentation (and checked from playgroud), I use that request (Python3 & requests):
https://pastebin.com/bicQftLE request_template = "https://api.toodledo.com/3/account/token.php" payload = {'grant_type': 'authorization_code', 'code': auth_code} request = request_template.format(**{'code':auth_code, 'CLIENT_ID': CLIENT_ID, 'CLIENT_SECRET': CLIENT_SECRET}) from requests.auth import HTTPBasicAuth r = requests.post(request, params=payload,auth=HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)) if r.status_code!=200: print("ERROR1") save_page(r.text) But I always get {"errorCode":102,"errorDesc":"The grant type was not specified in the request"} what is my mistake? |
Jake Toodledo Founder |
I am not very familiar with Python, but I have a guess. From the pastbin, on line 4, you are inserting the code into the request, but you aren't inserting the grant_type. I see that this is done on line 2, but maybe it needs to be in both places. If that isn't it, then Im not sure what the problem is. You may have to inspect the actual network call, because I suspect that for some reason the payload is not being added.
|
ishayahu |
Posted by Jake:
[quoteYou may have to inspect the actual network call, because I suspect that for some reason the payload is not being added.[/quote] I did it. Here is request headers, url and body: req_body >>> None req_headers >>> {'User-Agent': 'python-requests/2.13.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0', 'Authorization': 'Basic dG9vZGxlZG9ydXM6YXBpU09NRURBVEE='} req_url >>> 'https://api.toodledo.com/3/account/token.php?grant_type=authorization_code&code=4593a75d57660672c19 3bc2b95a9a27a7c14d488' it looks like it should be |
ishayahu |
OMG, I should send data in POST, not in GET
Sorry, my fault |
You cannot reply yet
U Back to topic home
R Post a reply
To participate in these forums, you must be signed in.