TeslaSwift
TeslaSwift copied to clipboard
Token expires issue
I just recently started using this library, and have faced some issues with the token after logging in.
Same as in the demo, I am storing the api.token.jsonString
, and loading the value in AppDelegate
by using reuse
. When I print it, I get this:
{
"expires_in" : 28800,
"refresh_token" : "xxxxxxxx",
"id_token" : "xxxxxxxx",
"token_type" : "Bearer",
"access_token" : "xxxxxxxx",
"created_at" : 1664609888.676774
}
I changed to xxxxxxxx
so the code get's smaller. But, in the expires_in
it says 28800
. If that is in seconds, that is equals to 8 hours. In my app I get logged out a few times a day. May that be the reason? And what can I do to stay logged in?
@jonasman Do you have a solution for this, sir? :-)
I think I have the same issue. I've even setup background tasks to run in my app hoping that it would keep logging in, but it's only running background once a day. It logged out over the course of 2 days.
Is this still valid?
There were some updates to the token code recently
if not maybe we need to implement some token refresh
When you say updates to the token code recently - can you point them out? I don't see any new releases to this library to see what that could be.
@akac https://github.com/jonasman/TeslaSwift/commit/f3da37fb7721ba05924b9a956f155219ab1bd274
I'll have to test that and see.
if something is not working and you want to debug it, refreshWebToken
is the function that should refresh the web token
@akac and @Sniperwolf881 any news?
i looked into this, tesla seems to send a validity of 8h for the token, but from my testing the token is not valid this long, probably only 5mins. One way to fix is to force a 5mins token validity instead of using whatever Tesla sends