core icon indicating copy to clipboard operation
core copied to clipboard

Alexa integration: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid

Open msp1974 opened this issue 4 years ago • 66 comments

The problem

I get frequent log entries with the following message:

Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.

The integration seems to continue to work but this gets logged about every 1-2 hours. Presume when this happens it is requesting a new access token, so should this be in the error log? Is it part of normal operation?

Environment

  • Home Assistant Core release with the issue: v0.110.0
  • Last working Home Assistant Core release (if known): don't know. At least before v0.106.0
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker with HassIO
  • Integration causing this issue: Alexa
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/alexa/

Problem-relevant configuration.yaml

This is setup with UI config


Traceback/Error logs

The first occurred is about 2 hours after last rebooting.

Log Details (ERROR)
Logger: homeassistant.components.alexa.state_report
Source: components/alexa/state_report.py:49
Integration: Amazon Alexa (documentation, issues)
First occurred: 0:12:50 (7 occurrences)
Last logged: 11:35:52

Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.

Additional information

msp1974 avatar May 21 '20 11:05 msp1974

alexa documentation alexa source (message by IssueLinks)

This will usually resolve itself once the old tokens expire. But it you want to force it, disable the Home Assistant skill in the Alexa app and then re-enabled it. Restart HA as needed.

ochlocracy avatar May 21 '20 12:05 ochlocracy

@msp1974 Are you still experiencing this?

ochlocracy avatar May 24 '20 15:05 ochlocracy

Yes. It now shows 32 occurences since 21st May. Havent disabled/re-enabled the skill yet but will do tonight and report back.

msp1974 avatar May 24 '20 20:05 msp1974

So i disabled the Alexa integration in HA Cloud, disabled the skill in Alexa, rebooted and added it all back/relinked etc and the same messages started appearing a few hours after, so sorry, this did not seem to fix it.

`Log Details (ERROR) Logger: homeassistant.components.alexa.state_report Source: components/alexa/state_report.py:49 Integration: Amazon Alexa (documentation, issues) First occurred: 1:07:45 (3 occurrences) Last logged: 9:19:46

Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.`

msp1974 avatar May 25 '20 11:05 msp1974

As an FYI, I had the same issue. I did as suggested by re-enabling the skill, and restarted HA. After about an hour, I don't see these logs anymore.

tommyjlong avatar May 25 '20 21:05 tommyjlong

I am having the same issue. I haven't done anything about it because it does not appear to have any significant effect on alexa cloud performance.

bturrie avatar Jun 09 '20 14:06 bturrie

Getting the same suddenly out of the blue from yesterday. Using HA 0.112.4 installed in python venv on RPi 3b+ Everything seems to be working fine, but the sudden error in logs bothers me. I've tried re-enabling the HA skill in Alexa app and restarting HA but the error keeps popping up every now and then.

hugalafutro avatar Jul 15 '20 11:07 hugalafutro

hello, getting the same issue, which appears every often minutes : Logger: homeassistant.components.alexa.state_report Source: components/alexa/state_report.py:49 Integration: Amazon Alexa (documentation, issues) First occurred: 12 juillet 2020 à 20:35:31 (2989 occurrences) Last logged: 10:16:28

release and recreate skill association, restart HA, control that lambda test is OK, control port 8123 and 443 is OK from inside and outside. control the validity of the secret and client_id, control that both secret client_id are declared inside configuration.yaml.

So i'm stock with this issue.

as mentioned above , i don't know if this issue have or havn't an effect, but i suspect that 'return status' of devices aren't correctly fetched and displayed by HA thanks to help to solve

jluc2808 avatar Jul 16 '20 08:07 jluc2808

but i suspect that 'return status' of devices aren't correctly fetched and displayed by HA

I don't think it even affects this as I only use HA skill in alexa through which I control everything connected to HA including hue, tp-link and meross plugs / lights for which I needed separate alexa skills before, and the status of the devices is always correct in both HA and Alexa. Have you noticed some discrepancies in the entity states between alexa and HA?

That said I'd still like the error gone and / or explained as it must be presumably stemming from some underlying issue. This worries me especially since I subscribed to the HA cloud service only for the alexa integration and couple weeks later it starts throwing out errors.

There's been at least 3 updates to HA since it started happening to me. I didn't do any update, nor restart nor change anything in HA config the day it started and suddenly this error pops up in logs sometimes 10 times a day, sometimes 10 times an hour. Although nowhere near the 2k+ occurrences from your log.

hugalafutro avatar Jul 25 '20 23:07 hugalafutro

but i suspect that 'return status' of devices aren't correctly fetched and displayed by HA

I don't think it even affects this as I only use HA skill in alexa through which I control everything connected to HA including hue, tp-link and meross plugs / lights for which I needed separate alexa skills before, and the status of the devices is always correct in both HA and Alexa. Have you noticed some discrepancies in the entity states between alexa and HA?

That said I'd still like the error gone and / or explained as it must be presumably stemming from some underlying issue. This worries me especially since I subscribed to the HA cloud service only for the alexa integration and couple weeks later it starts throwing out errors.

There's been at least 3 updates to HA since it started happening to me. I didn't do any update, nor restart nor change anything in HA config the day it started and suddenly this error pops up in logs sometimes 10 times a day, sometimes 10 times an hour. Although nowhere near the 2k+ occurrences from your log.

i'm quite with the same situation, i don't noticed discrepancies in the state as i didn't checked the return status of each object after using alexa (generaly i use alexa order when i'm not with my smartphone or tablet or PC to send the order, so it's not easy to control with this usage). if i'm looking in the log the error occured 3177 time in 3 days (life time of HA till my last restart). So it could be a good reason to fetch why the error append.

jluc2808 avatar Jul 26 '20 06:07 jluc2808

Are there any suggestions on how to prevent this from happening? I've been subscribed to the HA cloud for several months now. However, this just started happening to me for about 1-2 weeks ago.

I've already disabled/re-enabled the HA Alexa skill and re-authenticated with an Amazon Captcha code in HA. However, I'm still seeing these errors in my log regularly.

mkanet avatar Jul 30 '20 02:07 mkanet

Anybody still getting these in HA 0.113.2 ? Haven't seen it since updating to this version, but no idea if it's fixed or if I'll get it later as I only get it sparsely compared to other commenters.

hugalafutro avatar Jul 31 '20 11:07 hugalafutro

i'm now under HA 113.2 and still get the error, every 10 minutes

jluc2808 avatar Jul 31 '20 15:07 jluc2808

Anybody still getting these in HA 0.113.2 ? Haven't seen it since updating to this version, but no idea if it's fixed or if I'll get it later as I only get it sparsely compared to other commenters.

Im using HA 113.2 and still get the error regularly.

mkanet avatar Jul 31 '20 17:07 mkanet

Spoke too soon, the error popped up again an hour ago.

hugalafutro avatar Jul 31 '20 22:07 hugalafutro

Spoke too soon, the error popped up again an hour ago.

I noticed that I don't get these errors until after Home Assistant has been up and running running for a while. It seems like something triggers these errors. Once I get this error, I'll get the errors regularly.

mkanet avatar Jul 31 '20 22:07 mkanet

If you're using a custom built skill verify the skill still has the permission configured to "Send Alexa Events" in the Alexa developer console.

Verify your Alexa configuration is using the correct endpoint for your locale, and your client_id and client_secret still match with what's provided in developer console for your skill.

  locale: en-US
  endpoint: https://api.amazonalexa.com/v3/events
  client_id: !secret alexa_client_id
  client_secret: !secret alexa_client_secret

If you're using HA Cloud/Nubu Casa, or roll your own custom skill try the following:

This is a long shot.... but, try disabling/re-enabling the Alexa HA skill from the Alexa Web based app. e.g. https://alexa.amazon.com

I once had an unrelated issue during development causing issues with the Alexa API; I eventually reached out to Alexa Developer support, and this was the solution that eventually fixed the issue I was having at the time. Previously, I'd had been using only the mobile app to disable/re-enable the skill.

If you've been using this web app, try from the mobile app instead. Also verify all the devices in the Alexa app are connected via Home Assistant and available. If not, delete the device from the Alexa app, and re-discover.

There is also a "nuclear" command to Remove All devices in the web app... If you want to try removing everything, disabling the skill, and trying a fresh start.

ochlocracy avatar Aug 02 '20 14:08 ochlocracy

I have a custom skill enabled in my Alexa app. However, my Home Assistant setup doesn't utilize that skill, at least not to my knowledge. ...Does Nabu Casa try to access ALL my skills in my Alexa app; including my custom Developer skill?

mkanet avatar Aug 02 '20 18:08 mkanet

There are several ways to integrate Alexa into Home Assistant, I'll clarify for the purpose of this issue. But the INVALID_ACCESS_TOKEN_EXCEPTION message is related to the Smart Home Integration:

For Alexa Smart Home integration you should choose to use one of the following:

  1. Use Home Assistant Cloud/Nabu Casa Subscription, with the Official Home Assistant Skill from Nabu Casa
  2. Build your own Private Alexa Smart Home Skill, with your own AWS Lambda Function such as HASSKA,this would be your own private developer skill and doesn't need to be published.

If you're using both smart home integrations... then that's likely the cause of the problem.

If you're using Nabu Casa, then all the configuration should be done through the UI or in the cloud: configuration.

Note: You could also have your own custom Alexa skill that uses Home Assistant intents functionality, but that is completely separate from the Smart Home integration.

ochlocracy avatar Aug 02 '20 19:08 ochlocracy

My private Alexa skill doesn't have anything to do with smart home. It's used to control Event Ghost software with voice commands (unrelated to HA). I only have Nabu Casa enabled in the HA GUI. I don't have any Nabu Casa configuration settings in configuration.yaml. I only use Nabu Casa to sync my HA scripts to Alexa so the scripts are accessible to Alexa Scenes. However I'm still getting these errors on occasion.

mkanet avatar Aug 02 '20 20:08 mkanet

I do not have neither I've ever had private alexa skill. I only ever used the Nabu Casa configuration in UI and official Home Assistant skill in Alexa app on phone. Never configured anything Alexa / cloud related in .yaml manually. This was running fine for months, and still is, but since about month ago this error started popping up. Everything still works, devices and the state they're in show correctly in both HA and Alexa, but the error has to be coming from somewhere.

hugalafutro avatar Aug 02 '20 20:08 hugalafutro

Mine also happened recently. I haven't had any changes to my configuration. I have only updated Home Assistant versions. I can check my private Alexa skill for that setting, however, I've been using it that way for a relatively long time before this issue started.

mkanet avatar Aug 02 '20 22:08 mkanet

Mine began as soon as connect Alexa with ha. I have checked every recommandations, restart, reconnect alexa, tested aws, still the same

jluc2808 avatar Aug 02 '20 22:08 jluc2808

cloud documentation cloud source (message by IssueLinks)

Hey there @home-assistant/cloud, mind taking a look at this issue as its been labeled with an integration (cloud) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

I need assistance to enable: "Send Alexa Events" permission for my private skill. Could someone please kindly tell me how/where to navigate to this setting in my skill under the Developer Console? The closest I can get is the screenshot below; which isn't correct: Send-Alexa-Events

Thanks!

mkanet avatar Aug 03 '20 17:08 mkanet

@mkanet Home Assistant only send events to Alexa for "Smart Home" Skills. Your private skill is a "Custom" Skill. For Custom skills you want to use the intent scripting. The INVALID_ACCESS_TOKEN_EXCEPTION error has nothing to do with your "Custom" skill.

ochlocracy avatar Aug 03 '20 17:08 ochlocracy

@oischinger thanks for letting me know. There isn't anything more I can do to prevent these errors. I only have Nabu Casa enabled with no configuration settings in my configuration.yaml file. I have already tried disabling/enabling my Alexa skill in the Alexa app with no luck.

The only other thing I have that's related to Alexa is the HACS addon called, Alexa Media Player. Would that have anything to do with this error? There's nothing else I can think of that would cause this error; other than the Nabu Casa cloud integration itself.

mkanet avatar Aug 03 '20 18:08 mkanet

Just for the record, I have Nabu Casa installed and configured for Alexa integration, I have been seeing the invalid access token issue for some days and yesterday I bit the bullet and removed all integration related to Alexa and reinstalled. This morning I woke up to the same error again. It doesn't seem to a major impact to operation of the integration, I have yet to identify any functionality affected. I am on the latest HA version 0.114-3 running in a docker container on Synology NAS.

rjenx avatar Aug 23 '20 08:08 rjenx