ardevd / jlrpy

Python library for interacting with the JLR Remote Car API
MIT License
84 stars 30 forks source link

Refresh token #61

Closed benthehorn closed 5 years ago

benthehorn commented 5 years ago

Just for information, the refresh token can be used to get a new token, without needing username/password after the initial login. You just need to keep it refreshed before you reach the expiry time. `def refresh_token():

device_id = "alongdeviceid"
url = "https://jlp-ifas.wirelesscar.net/ifas/jlr/tokens"
payload = {
    "grant_type": "refresh_token",
    "refresh_token": "arefreshtoken",
}
headers = {
    "Authorization": "Basic YXM6YXNwYXNz",
    "Content-Type": "application/json",
    "X-Device-Id": device_id,
}
res = requests.post(url, headers=headers, json=payload)
json_response = res.json()
print(json_response)`
ardevd commented 5 years ago

Cool! Nice find. That's actually very useful!

ardevd commented 5 years ago

@benthehorn have you actually gotten this to work? The request does indeed return a new access token and refresh token but subsequent requests where you actually use that new access token seems to return a 401 for me.

ardevd commented 5 years ago

Nevermind. You need to register the device id and log in the user after refreshing the access token and then it works.