Differences between token in the database and using username/password for logging in #315
-
|
I am trying to add Garmin conenctivity to a PWA web app. It basically checks the database for a token and uses it if it exists but otherwise prompts the user for usernname and password before then saving the token produced in the database for future use. So, I am wondering how others have handled this situation? I don't want to prompt for username/password every time and I don't particularly want to store the token as json in a directory on the server, as should surely be able to store the json in the database? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
I've been digigng around this for a few days and it looks like GarminConnect (and more likely just Garmin) doesn't restore everything from the token that is returned from a full login. So yes you can connect, refresh expired tokens and get some data but not get at anything useful like step count data etc without first logging in with the username and password (making the whole token thing pretty much a complete waste of time). |
Beta Was this translation helpful? Give feedback.
-
|
I think you simply using it wrong, this package was made by me to get Garmin Connect data in home assistant, and that's also storing the tokens to re-login every x minutes without having to use password nor MFA... When a user installs the integration it saves the token data in one field, (or when re-auth is needed) https://github.com/cyberjunky/home-assistant-garmin_connect/blob/main/custom_components/garmin_connect/config_flow.py#L129 and later uses that over and over: https://github.com/cyberjunky/home-assistant-garmin_connect/blob/main/custom_components/garmin_connect/__init__.py#L203 you also have two example programs to look at example.py and demo.py |
Beta Was this translation helpful? Give feedback.
-
|
Simply use the token to login if you have it, otherwise (at new fresh usage of your script or if you get an auth error) ask for user/passwd and store returned token, its running like that for years.. |
Beta Was this translation helpful? Give feedback.
I think you simply using it wrong, this package was made by me to get Garmin Connect data in home assistant, and that's also storing the tokens to re-login every x minutes without having to use password nor MFA... When a user installs the integration it saves the token data in one field, (or when re-auth is needed) https://github.com/cyberjunky/home-assistant-garmin_connect/blob/main/custom_components/garmin_connect/config_flow.py#L129 and later uses that over and over: https://github.com/cyberjunky/home-assistant-garmin_connect/blob/main/custom_components/garmin_connect/__init__.py#L203 you also have two example programs to look at example.py and demo.py