-
Notifications
You must be signed in to change notification settings - Fork 306
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
RE-Authentication Required multiple times a day. #2821
Comments
Same thing happening to me, again no changes, however, now requires repeated re authentication |
I can confirm, same issue for me |
I'm stay in same situation. I'm using:
I don't use proxy in my network, like pihole or similar. Thank you very much for your job. |
ah! I thought it was only me! Also in the AU |
Same here. Also using AU domain |
Same issue with .DE domain |
Same issue .au domain please help |
Same issue in AU |
same here to AU as well |
Add me to the list too. AU domain, 2025.2.4 |
Is everyone in here using AU? |
No, i'm using amazon.it, but using Amazon 2-step verification. |
As mentioned before. I am AU - I had this pop up multiple times over the days but yesterday it didn’t happen and AMP is working fine. I had to make sure my local IP in AMP settings was my actual IP and not home assistant.local. It then took me to the amazon page where I had to log in. I’ve done this 10 times over the last 4-5 days but yesterday and so far today I’ve had no re-authentication dialogues |
In AU as well. This is happening to me very regularly now. |
Same here. AU domain. |
Hey let's keep it on topic to the original issue please, OTP and 2SV errors are not this issue. Nor is banter about reliance on HA. |
I'll move from #2815 and join here. ref. #2815 (comment) I thought of it, so I tried accessing to From this, I think that for some reason your login session was terminated and you were asked to log in again. |
The Re-auth error seems to be gone, but my devices do no longer have an entity showing the temps of capable devices |
The login windows changed at least 6 months ago and caused lots of grief back then. The 'fix' back then was to change The question now seems to be why does AMP think the session is closed and force a reauth... |
Yeah, the re-auth flow works seamlessly for me - select already registered, login, do 2FA, return to HA. Only problem is that an hour later I need to do it again. |
I don't know if that will have an effect, but... I just set up an Amazon passkey in the Chrome browser where I logged in to Google. After that, a re-authentication request occurred, so I clicked the re-authentication button, and the re-authentication was completed without me having to enter my email address, password, or OTP (the screen for that didn't even appear). Perhaps there won't be any re-authentication requests in the future. I'll wait and see for a while. |
No, a re-authentication request occurred. |
@nao-pon
|
This is a shot in the dark but try changing line 164 from:
to:
to see if pre-empting the access token expiration helps or not. |
Please check your home-assistant.log for debug statements like:
|
I think this issue can be reproduced by continuing to play something through Amazon in the media player. I also think it is more likely to occur when performing frequent operations such as selecting songs. I also think that it may be triggered by sending notifications via automation while music is playing. I've given various code snippets here at random, but they didn't work, so I think this change will finally solve the problem. |
Based on what I've seen so far, I think Amazon may be doing some kind of rate limiting. For now, you can ignore the OTP input screen, but we should be take care that it may become mandatory in the future. But this is just my guess. |
I am trying to make as few requests to Amazon as possible. First, I tried to stop polling media_player when I could receive http2 push. Then, I noticed that sometimes the status and details of the currently playing content were not updated. When I checked the data received from Amazon, I noticed that it was received as command: NotifyNowPlayingUpdated, but it was not being used to update. I receive command: NotifyNowPlayingUpdated immediately after receiving command: PUSH_AUDIO_PLAYER_STATE. Since command: PUSH_AUDIO_PLAYER_STATE is processed properly, the playback state is updated, but the song information is not updated. The data looks like this:
It looks like 'mediaReferenceId': '686c5ae1-8663-47df-ab09-3bd1f49974c2 : 5' and 'mediaId': '686c5ae1-8663-47df-ab09-3bd1f49974c2 : 5' are linked. What is the best approach to handle this data properly? Handling this will eliminate the frequent polling required when using the media player, and I believe this will reduce API requests significantly. |
|
Both of those commands are initially seen and processed by
However, the 2nd command does not contain a serial number and is just a media update from Amazon so it looks look like it would not trigger async_dispatcher_send. I'd add additional debug in there to double check. |
That procedure is clearly documented in the wiki FYI, you can enter the code with or without spaces since config_flow.py strips them.
|
I have this in my config as I am using DuckDNS and it works:
I can't use http:// and 8123. I can only access my HA instance from https://192.168.1.173:8123/ |
DuckDNS is simply dynamic DNS and is only to provide access to HA via your public URL.
Well, you are NOT getting an SSL certificate via that URL! HTTP SSL port is 443 unless you have a proxy forwarding HTTPS 443 to a nonstandard port.
HA default port is 8123 and is HTTP
my
I use this add-on for HA certificate: Also, I have:
The homeassistant native container's http port is 8123 and https port is 443. |
@danielbrunt57 I've got it set up with AMP's built-in 2SV authentication, but that didn't help with the issue of needing to re-authenticate. I think the call to get_state() is causing the issue, so by properly handling |
I send PR #2827, Please do a code review. |
Thanks to PR #2827, it now works almost without any problems, but re-authentication requests still occur occasionally. After that, I re-authenticated, but the login session expired again immediately, and this time the re-authentication button was not displayed, so I restarted the HA and re-authenticated. Strangely, I then noticed that the Alexa app on my Android smartphone had been logged out. I don't know why. I've attached the logs. |
I tried changing alexapy/helpers.py L.149- to the following: Will this allow me to try logging in again and get a new session? except (JSONDecodeError, CookieError) as ex:
_LOGGER.warning(
"%s.%s(%s, %s): A login error occurred: %s",
func.__module__[func.__module__.find(".") + 1 :],
func.__name__,
obfuscate(args),
obfuscate(kwargs),
EXCEPTION_TEMPLATE.format(type(ex).__name__, ex.args),
)
if login:
if not await login.test_loggedin():
login.status["login_successful"] = False
raise AlexapyLoginError from ex
return None
else:
raise AlexapyLoginError from ex |
For those of you experiencing this issue, we believe this issue will be resolved in issue #2827. However, we have not yet fully tested the issue, so we would appreciate your help in testing it. Thank you! |
I have just applied #2827. Will report back on whether there are any issues, or not, thank you. |
Have also applied it |
Thanks! 👍 This was my first time looking at the AMP source code, so it was a bit of a detour, but with #2827, I've been able to use it comfortably in my environment as before. |
So far so good! Prior to #2827 I'd have several authentication failures overnight - working fine this morning with none yet... |
Everything is working nicely with mine too. No authentication requests and the log is quiet. I was experiencing the issue right up until a few minutes before applying the fix. |
I haven’t updated - still on 5.4.0 and the requests stopped a few days ago :/ such a strange issue! |
Actually I just received something in the logs. Looks the same as Glen's screenshot above. Logger: alexapy.helpers alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f4272f380>,), {}): A login error occurred: An exception of type JSONDecodeError occurred. Arguments: ('Expecting value: line 1 column 1 (char 0)',) And Logger: custom_components.alexa_media.helpers alexa_media.media_player.refresh: Successfully re-login after a login error for |
Thank you for participating in the operation verification. I don't know why, but since this problem occurred, Amazon has often returned a login screen when calling My approach is to use the previously unused state push for media players from Amazon, and to eliminate most As a side effect, this means that media player status updates are now reflected more immediately than before. In the current version #2827, the log output has been adjusted, and only the following message is output by alexapy:
If there is no problem with the operation, you can ignore this log. |
Still working well for me, thank you nao-pon. |
For the past 3/4 days this has been working for me without any issues. |
I've not changed anything and it's still happening for me on 5.4.0, I just got notified by my automation twice in the last 10 minutes that Alexa needs a re-login. It's still working though - notice the integration is not flagged as in an error state. It's nuisance factor only at this point as AMP is still functioning.
|
Mine was happening right up until I applied the fix and I think that it is to do with how we are using it. I am pretty sure I was being kicked out every time I did something with music |
Describe the bug
Having to re-authenticate AMP integration multiple times a day.
This has only happened in the last couple of days, no changes have occurred on HomeAssistant, Amazon account or anything else. Not sure why it's happening.
To Reproduce
Leave system running, AMP integration fails, have to re-authenticate to get it working again.
Expected behavior
Not have to re-authenticate multiple times a day.
Screenshots
System details
const.py
or HA startup log):5.4.0pip show alexapy
in homeasssistant container or HA startup log):Debug Logs (alexa_media & alexapy)
Please provide logs.
Logger: alexapy.helpers
Source: custom_components/alexa_media/media_player.py:661
integration: Alexa Media Player (documentation, issues)
First occurred: 7:25:02 PM (21 occurrences)
Last logged: 7:38:11 PM
Logger: alexapy.helpers
Source: custom_components/alexa_media/init.py:729
integration: Alexa Media Player (documentation, issues)
First occurred: 7:29:23 PM (2 occurrences)
Last logged: 7:29:23 PM
alexaapi.get_notifications((<alexapy.alexalogin.AlexaLogin object at 0x7f84026ef4d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)
Additional context
The text was updated successfully, but these errors were encountered: