API device code grant flow assistance
Hi
I use the "password grant flow" method of accessing the Tado API using code built on an ESP8266. I have received a mail telling me that I will now need to move to a "device code grant flow" authorisation process, and example of the process is given.
When I follow the example I get to a point which shows this request:
req = requests.post(
"https://login.tado.com/oauth2/token",
params=dict(
client_id="1bb50063-6b0c-4d11-bd99-387f4a91cc46",
device_code="XXX_code_XXX",
grant_type="urn:ietf:params:oauth:grant-type:device_code",
)
)
Giving this response:
{'access_token': 'myAccessToken',
'expires_in': 3599,
'refresh_token': 'myRefreshToken',
'scope': 'offline_access',
'token_type': 'Bearer',
'userId': '...'}
However when I execute for my device code I get:
{
"access_token": "myAccessToken",
"expires_in": 599,
"token_type": "Bearer",
"userId": "…"
}
So, differing expiry and no refresh_token.
Is there somebody that has successfully implemented this who can steer me in the right direction please?
I am for from an expert in anything HTTP(s), so treat me as a novice please.
Cheers.
Answers
-
Not sure if this helps you a lot, but I've implemented it in JS yestersday
Step 1
Step 2
and it works as expected.
After "Step 2" I am receiving access_token and refresh_token
0 -
I'm having the same problem when I call
https://login.tado.com/oauth2/token
with aPOST
and I adddevice_code
pluscode I got from first stage
and thegrant_type
urn:ietf:params:oauth:grant-type:device_code
I get this back. Without a refreshToken
{
"access_token": "myAccessToken",
"expires_in": 599,
"scope": "offline_access\n\n",
"token_type": "Bearer",
"userId": "myUserId"
}And if I call the call the endpoint again with the same value's I get
{
"error": "invalid_request",
"error_description": "The request has an invalid parameter: device_code",
"error_reason": "invalid_device_code"
}
And I need to do thedevice_authorize
step again to get a newdevice_code
I am using Postman to do test these requests
0 -
I worked it out in the end. It involved messing about with quotes around the grant type string.
What seems to happen is it doesn't see the grant type that is being requested and rather than failing in any way gives you this different result. Once you get the format of that line right everything turned up without issue.
Good luck!1