timdorr / tesla-api

🚘 A Ruby gem and unofficial documentation of Tesla's JSON API for the Model S, 3, X, and Y.

Home Page:https://tesla-api.timdorr.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Token expire

SiennaMills1 opened this issue · comments

Not sure if this should be in issues or discussion, but I am having some trouble with the access token.

When I return the value, it tells me:

"expires_in" : 28800,

So I have to renew the access token every 8 hour. I am just using my app for myself currently, so in my app I transfer a JSON file with the access token to my phones document directory, so Shortcut's app can read that file and open/lock doors etc using the same access token. But now I have to open my app and update to the new access token every 8 hour.

Any tips on how to get my access token to last longer?

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh
It takes maybe a second

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh It takes maybe a second

Ahh, I see! How long does the refresh token last until expire then?

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh It takes maybe a second

Ahh, I see! How long does the refresh token last until expire then?

There doesn't appear to be an expiration, but just save the refresh token that's returned when you refresh and use that at the next refresh

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh It takes maybe a second

Ahh, I see! How long does the refresh token last until expire then?

There doesn't appear to be an expiration, but just save the refresh token that's returned when you refresh and use that at the next refresh

Yes, but the refresh token can't be used like this:
image

Language is in Norwegian, sorry about that, but as you can see - here I need to use the Bearer AccessToken, the RefreshToken won't work here.

EDIT: When running https://owner-api.teslamotors.com/api/1/vehicles/ID/vehicle_data like above, I get the following message returned:
error":"unsupported SSO app , and that is when using the api.token.refreshToken. When using the api.token.accesstoken it works fine.

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh It takes maybe a second

Ahh, I see! How long does the refresh token last until expire then?

There doesn't appear to be an expiration, but just save the refresh token that's returned when you refresh and use that at the next refresh

Yes, but the refresh token can't be used like this: image

Language is in Norwegian, sorry about that, but as you can see - here I need to use the Bearer AccessToken, the RefreshToken won't work here.

EDIT: When running https://owner-api.teslamotors.com/api/1/vehicles/ID/vehicle_data like above, I get the following message returned: error":"unsupported SSO app , and that is when using the api.token.refreshToken. When using the api.token.accesstoken it works fine.

Yes, you store the full token (adding a create date/time) and use the access part for access, when that expires you use the refresh to refresh

I don't know how the code you're running is coded

#573

Oh, damn! So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to create a new token manually?

REFRESHING a token is really simple, no need to go through the creation of a new token

That's what I ment: So I can't make the shortcut app do stuff with my Tesla for more then 8 hours? And then I have to refresh the token manually?

As I say on the other PR, the first check you should do when you enter your code is - has the 8 hours expired, if so refresh It takes maybe a second

Ahh, I see! How long does the refresh token last until expire then?

There doesn't appear to be an expiration, but just save the refresh token that's returned when you refresh and use that at the next refresh

Yes, but the refresh token can't be used like this: image
Language is in Norwegian, sorry about that, but as you can see - here I need to use the Bearer AccessToken, the RefreshToken won't work here.
EDIT: When running https://owner-api.teslamotors.com/api/1/vehicles/ID/vehicle_data like above, I get the following message returned: error":"unsupported SSO app , and that is when using the api.token.refreshToken. When using the api.token.accesstoken it works fine.

Yes, you store the full token (adding a create date/time) and use the access part for access, when that expires you use the refresh to refresh

I don't know how the code you're running is coded

Yea, so it doesn't looks like I can get this to work with Siri, without having to update the access token in the JSON file after every 8 hour.