alexa_media_player: Endless authentication requests for EU domains due to 500 error

Describe the bug An endless request of auth is happening on AMP @amazon.it.

Alexa Media Reauthentication Required
Reauthenticate [](mailto:omissis) on the [Integrations](https://omissis:8123/config/integrations) page. Relogin required after 0:00:13.833459 and 15 api calls.

To Reproduce

System details

  • Home-assistant (version): 2022.7
  • Hassio (Yes/No): NO (Core@Docker)
  • alexa_media (version from const.py or HA startup): 4.10
  • alexapy (version from pip show alexapy or HA startup): 1.26.1
  • Amazon [2FA is enabled]: Yes

Logs alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f8ced65f070>,), {}): An error occured accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)

Additional context Started a couple of days ago.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 67
  • Comments: 151 (5 by maintainers)

Most upvoted comments

Guys, no use saying I have the same problem. Just subscribe to the issue here to get updates and I am pretty sure it will be looked at.

Ok. Please do not add comments unless you’re adding something. Me too posts need to be a +1 on the original issue. It looks like it’s Europe mainly as US isn’t seeing anything. However, I can’t figure out the cause without someone posting the alexapy logs and the result from Amazon causing the reauth requirement. If the me too posts continue, I’ll have to lock the thread since stuff is being buried.

Same problem here, via UK Amazon

Guys as you can see the problem occur in different method of the integration, there is some fields returned from Amazon that it is null and offend the integration, I do not thing the regenerating configurations and keys can help, we need this issue will be fixed at integration level I suppose

authentication issue started happening again, anyone else experiencing this ?. i am on 4.1.1. worked fine for over 12hours but several reuqests since this afternoon ( based in UK)

I did it once again and switched on extended debugging and got the following:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: alexapy.helpers
Source: custom_components/alexa_media/media_player.py:618 
Integration: Alexa Media Player (documentation, issues) 
First occurred: 12:03:10 (8 occurrences) 
Last logged: 12:03:11

alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f5f505270>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',)
alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f5f505c00>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',)
alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f60e1bf10>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',)
alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f60e2b160>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',)
alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f73ba1930>,), {}): A login error occured: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',)

Maybe helpful.

No way. Even with the latest version I had to reauthenticate two times. It seems that it works for a while then is fail again. I’ll try to enable alexapy logging to give more info to @alandtse

authentication issue started happening again, anyone else experiencing this ?. i am on 4.1.1. worked fine for over 12hours but several reuqests since this afternoon ( based in UK)

i registred a fresh 2FA app and used a new Key code when adding the config. so far (10hr +) it seems to be working and is persistent between restarts aswell. i am not sure if that makes any difference or if it will stick but so far so good.

Looks like it may be intermittent? Mine initially started logging the same error (as reported previously), then a few minutes later was ok again, I rebooted, it failed, then it managed to connect again. I’ve seen the same behaviour over the last hour or so, but seems to have stabilised again. Note @alandtse comments earlier, 500 is an internal server error - so if things are failing/changing at Amazon then we would see this behaviour intermittently - It might be helpful if the 500 error failed more gracefully and reported an error at Amazon (or waited a while before going red and asking for re-auth) - but given it’s a new thing, hard to code against.

An error occured accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ('Constructor parameter should be str',)

4.1.1 seems working fine (Italy) - at least about the auth. Btw no retrived data as expected.

Ok, turns out the 500 is likely the cause. Have a fix inbound to ignore it from now on. Please note that if there’s a 500 error, this may mean we won’t get any updated data on a playing Media player since it looks tied to the webplayer. This may be a hint that Amazon is going to deprecate alexa.amazon.com (at least in Europe) which is the main way we access info.

No other 500 errors, only this one

Thanks. 500 errors won’t require a relogin. With debug logs enabled on alexapy and alexa_media, look for the line where it says a reauth is required and then what happens right before it. That’s what I need to figure out why it’s closing out.

I’ll hope that this will help:

Logger: custom_components.alexa_media.config_flow Source: custom_components/alexa_media/config_flow.py:542 Integration: Alexa Media Player (documentation, issues) First occurred: 22:36:13 (1 occurrences) Last logged: 22:36:13

Unknown error: Constructor parameter should be str

Logger: alexapy.helpers Source: custom_components/alexa_media/config_flow.py:434 Integration: Alexa Media Player (documentation, issues) First occurred: 22:36:13 (1 occurrences) Last logged: 22:36:13

alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7f8f744e50>,), {‘data’: OrderedDict([(‘otp_secret’, ‘Z*****************************************_23Q’), (‘email’, 's_e@s******e’), (‘password’, ‘REDACTED 16 CHARS’), (‘url’, ‘amazon.de’), (‘debug’, True), (‘scan_interval’, 60), (‘include_devices’, ‘’), (‘exclude_devices’, ‘’), (‘reauth’, True)])}): An error occured accessing AlexaAPI: An exception of type TypeError occurred. Arguments: (‘Constructor parameter should be str’,)

This is interesting and may be something we need to fix. However, I’ll need the logs leading up to here as it’s not clear what is causing this error.

am i right, the problem appeared the hole last week spontaneously, now i can reconfigure but cant send commands or anything - always the same after one command i should reconfigure.

so are the devs aware and say anything?

@alandtse is usually very active with the development of this addon. He will probably not be reachable. Let’s give him some time to hear about this problem.

+1 spain amazon.es

Hi guys

This automation can help a bit in the mean time

Same here, Amazon.it seems like json reply is different from expected. It seems a server side change that require a patch in this integration.

It must be a server side issue then. Quoting the component documentation:

This is a custom component to allow control of Amazon Alexa devices in Homeassistant using the unofficial Alexa API. Please note this mimics the Alexa app so Amazon may cut off access at anytime.

Hopefully this has not happened and it’s simply an intermittent issue…

Could also be that something had been changed server side and to be changed within the API. And “anytime” does not mean every time 🙄