New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SmartThings spontaneous APIInvalidGrant on restart of HA (Cloudhook) #22529
Comments
Same issue here. |
So the error message occurs when the refresh token stored locally gets out of sync with your account in ST. Every time HASS starts up, it generates a new token and saves it back to storage. If you killed HASS before it could save the token (not exit gracefully), you can end up in this state and it's non-recoverable. All you should have to do is add the integration back to HASS using your access token. You never have to re-create the access token, unless you've lost it. |
Thank you (again). That is very likely what happened as I was noticing a significant slowdown on my machine at the time. As I didn't record the access token, I had to recreate it (and didn't record it again, of course). If this happens again, I'll make it a point to keep track of the token. I'll open a new issue if that doesn't fix the issue. |
@andrewsayre - is there a possibility of catching this exception and using it to re-authenticate, or be more pragmatic in writing the new refresh token as it is received? I've noticed this cropping up a lot when restarting/scaling/upgrading docker containers, and also if there's a config syntax error it may stop the loading process before the token is written, creating this error on next startup. |
Is it possible to update the token without removing smartthings from Home assistant ? |
Unfortunately once the error occurs, it's non-recoverable. There is no mechanism through the ST API at this time to re-authenticate/re-issue the refresh token.
We're using the same internal APIs as the rest of HA, so I would focus on ensuring your containers aren't killed but instead gracefully stopped. It's not just the ST integration that will be left in an invalid/unknown state. |
This topic is talking about a refresh token -- given there is no other mechanism to obtain it, I don't see how you would need to update it. |
Home Assistant release with the issue: 0.90.2
Last working Home Assistant release (if known): 0.90.2
Operating environment (Hass.io/Docker/Windows/etc.):
SmartThings access is via Nabu Casa Cloudhook
Component/platform:
https://www.home-assistant.io/components/smartthings/
Description of problem:
API key suddenly not working on restart of Home Assistant.
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):N/A
Traceback (if applicable):
Additional information:
This is very odd. SmartThings had been working with no issues since I set it up two days ago. I had been working on the Alexa TTS integration and had restarted HA several times. After probably the 10th restart over an hour or so, I started receiving this error message. I only noticed because HA was taking much longer than normal to come back up.
I did double-check and SmartThings still shows my access token:
Home Assistant — r:locations:, l:installedapps, r:scenes:, w:schedules, w:installedapps:, x:scenes:, r:installedapps:, r:schedules, x:devices:, l:devices, w:locations:, r:devices:, w:devices:, x:locations:, r:apps:, w:apps:
I went ahead and created a new access token, had to delete and reinstall the SmartApp and restarted HA and everything is working fine.
The text was updated successfully, but these errors were encountered: