Skip to content
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

reauth flow without a link to the config entry #2815

Open
z-master42 opened this issue Feb 1, 2025 · 7 comments
Open

reauth flow without a link to the config entry #2815

z-master42 opened this issue Feb 1, 2025 · 7 comments

Comments

@z-master42
Copy link
Contributor

Describe the bug
Detected that custom integration 'alexa_media' initialises a reauth flow without a link to the config entry at custom_components/alexa_media/init.py, line 1553: ] = await hass.config_entries.flow.async_init(. This will stop working in Home Assistant 2025.12,

To Reproduce
Wait until you receive a notification that the integration needs to be reconfigured and click through the individual steps. Then take a look at the log.

Expected behavior
No Warnings.

System details

  • Home Assistant version: 2025.1.4
  • alexa_media version (from const.py or HA startup log): 5.4.0
  • alexapy version (from pip show alexapy in homeasssistant container or HA startup log): 1.29.5
  • Is Amazon 2FA/2SV enabled <!---We will not debug login issues if unanswered---> (y/n): Y
  • Amazon Domain: DE

Debug Logs (alexa_media & alexapy)
-Detected that custom integration 'alexa_media' initialises a reauth flow without a link to the config entry at custom_components/alexa_media/init.py, line 1553: ] = await hass.config_entries.flow.async_init(. This will stop working in Home Assistant 2025.12, please create a bug report at https://github.com/alandtse/alexa_media_player/issues.

Additional context
Related developer blog entry: (https://developers.home-assistant.io/blog/2024/11/04/reauth-reconfigure-entry-id/).

@StefanW86
Copy link

same here, after reauthentication, it takes some hours and the integration need reauthentication again

@olflo
Copy link

olflo commented Feb 6, 2025

Are you using an automation to poll the status of Alexa Media Player or any other automation that triggers the API on a regular basis?

It seems like AMP now needs reauthentication after a specific number of API-Calls.

@StefanW86
Copy link

no, no automation. But i have 12 alexa devices at home

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Feb 6, 2025

Since I've never seen a notification that the integration needs to be reconfigured (and I fail to understand why others do), can someone who does test this code modification as per the blog post "Reauth and reconfigure flows need to be linked to a config entry"?

#    ] = await hass.config_entries.flow.async_init(
#        DOMAIN,
#        context={"source": "reauth"},
#        data={
#            CONF_EMAIL: account[CONF_EMAIL],
#            CONF_PASSWORD: account[CONF_PASSWORD],
#            CONF_URL: account[CONF_URL],
#            CONF_DEBUG: account[CONF_DEBUG],
#            CONF_INCLUDE_DEVICES: account[CONF_INCLUDE_DEVICES],
#            CONF_EXCLUDE_DEVICES: account[CONF_EXCLUDE_DEVICES],
#            CONF_SCAN_INTERVAL: (
#                account[CONF_SCAN_INTERVAL].total_seconds()
#                if isinstance(account[CONF_SCAN_INTERVAL], timedelta)
#                else account[CONF_SCAN_INTERVAL]
#            ),
#            CONF_OTPSECRET: account.get(CONF_OTPSECRET, ""),
#        },
#    )
    ] = await self.entry.async_start_reauth(self.hass)
    return False

I suspect that for those that do see this reauth sequence, their AMP installation is for some reason unable to refresh the token that is issued by Amazon when authentication is successful upon expiry of that token.

@danielbrunt57
Copy link
Collaborator

It seems like AMP now needs reauthentication after a specific number of API-Calls.

That's not the issue. Amazon issues a session token following successful authentication that AMP then uses to continue using the API without reauthenticating every single time. The session token has a limited lifetime and must be refreshed when it expires. I suspect the refresh is failing for some reason and is thereby forcing the reauth process to occur. It'll take someone with the issue to dig inside their debug logs and analyze if that's the issue and why it's failing.

no, no automation. But i have 12 alexa devices at home

I have 10 Alexa devices. The number of Alexa devices is not a factor.

@StefanW86
Copy link

should i enable the debug log for the media player integration? If the issue occurs, i can upload the file.

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Feb 6, 2025

That would be a good start.

logger:
  logs:
    alexapy: debug
    authcaptureproxy: debug
    custom_components.alexa_media: debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants