TeslaBuds / AuthAppForTesla

54 stars 13 forks source link

Add a shortcut to refresh the token #3

Closed karan301 closed 2 years ago

karan301 commented 3 years ago

Request Add a shortcut to refresh the access token.

I can currently get the access token or get the refresh token, but I’d like to be able to have the app refresh its its access token in the background using Shortcuts and return the updated access token.

Kemmey commented 3 years ago

Sure, I'll add both feature requests. Just be aware that currently the token will already be automatically renewed by the app when using the get token Siri actions - so your shortcuts don't need to manage this. But if you're sending the token further on to external systems and want as long-lived a token as possible, it's absolutely a good feature to have.

Cheers,

Kim

karan301 commented 3 years ago

Oh that’s awesome, I didn’t know that it auto-renews!

I currently have separate shortcuts for setup, auth, and individual actions. (Setup is one-time/infrequent and saves the token to iCloud Drive, actions all start with auth which fetches the token.) This lets me only need the app on one device for initial setup and other devices can simply reference the token from iCloud. It also reduces the dependencies, as only setup needs to reference a 3rd-party action.

I’d like for setup to store the token and it’s expiration date. I’d then have auth check/compare expiration date with current date. If it’s within 5 days (or expired), I could silently run setup to refresh the token and update the file in iCloud.

Kemmey commented 3 years ago

That makes absolute sense - would also make the shortcuts work independently on the Apple Watch without having the auth app as a watch app - which would be kind of pointless as it requires a browser :-D

I'll get it done!