alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.5k stars 286 forks source link

Unable to Login to Alexa Media Player stuck at integration page looping #1180

Closed jabshettys closed 3 years ago

jabshettys commented 3 years ago

Describe the bug

When authenticating using any method (with or without login proxy, with or without oauth), authentication is not happening and it is stuck on integration page, nothing happens it just keep looping. (Built in 2fa app key, username, and password are all corrent). Not even going to captcha.

To Reproduce Steps to reproduce the behavior: 1.Install Alexa media player through HACS 2.Clicked on Add the integration 3.Selected Alexa Media Player from the integration list. 4.Filled all the information(username, password, amazon.in or amazon.com, url: https://192.168.1.110:8123, Built In 2FA app key from qr code, Checked/Unchecked(Use Login Proxy Method, Enable Auth Token method). 2FA is Enabled as per wiki instruction

Expected behavior A clear and concise description of what you expected to happen.

It should pass this screen and go to captcha and proceed further

Screenshots If applicable, add screenshots to help explain your problem. image

System details

Logs Please provide logs. We'll be most likely asking for them anyway. 2021-02-12 01:35:11 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2021-02-12 01:37:22 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login 2021-02-12 01:39:46 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login 2021-02-12 01:40:56 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login

`Logger: custom_components.alexa_media.config_flow Source: custom_components/alexa_media/config_flow.py:514 Integration: alexa_media (documentation, issues) First occurred: 1:50:20 (2 occurrences) Last logged: 1:50:20

Unknown error:`

Additional context

I tried all the possible combination and options with authenticator app, and also with 2fa app key. Please help

alandtse commented 3 years ago

Please provide debug logs.

jabshettys commented 3 years ago

This is the one i got it from the log: If this is not correct, please help me where to find out.

021-02-12 18:21:44 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for alexa_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2021-02-12 18:21:44 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2021-02-12 18:21:52 DEBUG (MainThread) [custom_components.alexa_media] Importing config information for m******i@g*******m - amazon.in from configuration.yaml 2021-02-12 18:21:52 DEBUG (MainThread) [custom_components.alexa_media] Creating new config entry 2021-02-12 18:21:53 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login 2021-02-12 18:21:53 WARNING (MainThread) [custom_components.alexa_media.config_flow] Unknown error: Expecting value: line 1 column 1 (char 0) 2021-02-12 18:30:34 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login

alandtse commented 3 years ago

The template has instructions on how to generate the logs. Please follow them.

jabshettys commented 3 years ago

I have tried both component logging and debug login from the template. Please let me know if any other information is needed

Here is the log from Configuration > Logs section

2021-02-13 02:52:21 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for alexa_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2021-02-13 02:52:21 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2021-02-13 02:52:25 DEBUG (MainThread) [custom_components.alexa_media] Importing config information for m******i@g*******m - amazon.in from configuration.yaml 2021-02-13 02:52:25 DEBUG (MainThread) [custom_components.alexa_media] Creating new config entry 2021-02-13 02:52:26 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login 2021-02-13 02:52:26 WARNING (MainThread) [custom_components.alexa_media.config_flow] Unknown error: Expecting value: line 1 column 1 (char 0) 2021-02-13 03:02:49 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login

alandtse commented 3 years ago

You do not have any alexapy logs. Please enable it.

jabshettys commented 3 years ago

I have enabled already enabled the alexapy log.

This is what i have in my cofig file. Please help me if any other debug needs to enable. I am new to this its getting very difficult for me to fix this but i want to get this fixed. Thanks in advance. :)

`alexa: smart_home:

logger: default: critical logs:

for v 3.8.0

custom_components.alexa_media: debug  

for API debugging (verbose and intended for service debugging)

alexapy: debug

alexa_media: accounts:

alandtse commented 3 years ago

Please quote your yaml using ```. Also remove the Alexa Media info from your configuration. That is auto creating an entry. Manually add it on the integrations page.

psaggiomo commented 3 years ago

HI, I have the same issue:

In log I found:

2021-02-18 19:14:31 DEBUG (MainThread) [alexapy.alexalogin] Unable to load page for csrf: None 2021-02-18 19:14:31 DEBUG (MainThread) [alexapy.alexalogin] No csrf token found 2021-02-18 19:14:31 DEBUG (MainThread) [alexapy.alexalogin] GET:

alandtse commented 3 years ago

@psaggiomo I don't think you''re having the same issue as that error comes much later in the process than what the thread is about. Please confirm. If not, I'll mark your comment as off topic but feel free to open a new issue.

psaggiomo commented 3 years ago

@psaggiomo I don't think you''re having the same issue as that error comes much later in the process than what the thread is about. Please confirm. If not, I'll mark your comment as off topic but feel free to open a new issue.

Hi, was a my problem. I resolved it restarting router. Thanks.

jabshettys commented 3 years ago

I have enabled the alexapy logs

This is in the config file:

logger:

  default: critical
  logs:
# for v 1.0.0
    custom_components.alexa_media: debug  
# for API debugging (verbose and intended for service debugging)
    alexapy: debug

Let me know if anything else needs to be added in the config file.

and here is the log.

`2021-02-21 21:09:48 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2021-02-21 21:10:53 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login`

This is it nothing else in the log.

I am not sure whats happening what ever combination i try in the log it just says creating new login.

I tried to install the v3.4.0 and it worked like charm.

alandtse commented 3 years ago

You still haven't posted your logs for me to review.

EDIT: This is what I need.

 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login
 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.helpers] ****@****.com: Returning uuid {'uuid': 'f11ec3b8f27dfc2ef086c6c1fcd7a9a8', 'index': 0}
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Login created for ****@****.com - amazon.in
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Attempting oauth login to https://www.amazon.com/ap/signin?openid.return_to=https://www.amazon.com/ap/maplanding&openid.assoc_handle=amzn_dp_project_dee_ios&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&pageId=amzn_dp_project_dee_ios&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:373533316563306330663263386433393532333737306536363436383335643023413249564c5635564d32573831&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.response_type=token&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_a cess&language=en_IN
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Unable to generate OTP; 2FA app key not configured
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Unable to generate OTP; 2FA app key not configured
 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Starting proxy for ****@****.com - amazon.in
 2021-02-21 21:11:37 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Found flow_id; adding 127.0.0.1 to known_ips for 300 seconds
jabshettys commented 3 years ago

Closed by mistake ReOpening

jabshettys commented 3 years ago

As i stated in my previous comment that i get only this much log. attaching the screenshot.

HA Log

This is in my logger config:

logger:

  default: critical
  logs:
# for v 1.0.0
    custom_components.alexa_media: debug  
# for API debugging (verbose and intended for service debugging)
    alexapy: debug

Also, i tried enabling the advanced debugging to debug login issues as mentioned in your FAQ.

Requesting you to please guide me in fixing this issue. Thanks in advance.

What is working

I tried installing all the versions from 3.4.0 till 3.8.2 and it only worked till 3.4.2. starting from 3.4.3 nothing worked in the log it just says "Creating new login" as shown in the above screenshot.

Here is the log for 3.4.2:

EDIT. Log removed.

alandtse commented 3 years ago

The 3.4.2 log won't help me here. You also need to remove your sensitive data from the logs. Otherwise people can log in as you. Please check your homeassistant.log in your config directory.

alandtse commented 3 years ago

Please confirm that when you install the latest version you have alexapy 1.24.2. If you've ever installed alexapy manually, it may not update. You may have to delete it from the /config directory.

crudolphy commented 3 years ago

I am basically having the same problems. I got the notice that I needed to re-authorize. I did as I usually did and that was to sign out of my amazon account, then sign back in. I have 2FA enabled and when it sent me the code I entered into the Alexa Media player form. Problem was that it wouldn't show the captcha for me to copy and enter into the appropriate field. I restarted everything, even to the point of re-booting the host. That didn't help the captcha problem, so i deleted the intergration and went to re-install it. I have tried the older method where I enter in the 2FA code that Amazon texted me. It brings up a Amazon login in page I click to login in and it tells me that I need to allow cookies (Chrome). I went to settings in Chrome and allowed all cookies. Same problem. Then I tried the new method where your integration generates it's own 2FA code. I get logged into Amazon and go back to the integrations page in Home Assistant and it has a message box that says I need to open and external website. I click that and it takes me into an "alexa.amazon.com" login page. I re-log in and amazon either takes me to the Alexa web page or it opens a page that says I need to allow cookies. I have tried all methods the old way with no 2FA, the old way with 2FA and Amazon texts me the code, and then the new way using your generated code and still no love. Because it won't authenticate then it never "installs" the integration, it is no longer listed as an installed integration on the integration page. Please help!

alandtse commented 3 years ago

Please provide logs.

crudolphy commented 3 years ago

Sorry for the delay in getting back to you on this. I went out of town for a couple of days and wanted to be able to devote myself to this without hurrying. I have successfully installed the integration using the builtin 2FA ("Use Login Proxy Method"). However it was a rather involved process that was a bit confusing at times. I had already enabled 2FA with Amazon and had in fact enrolled both your app and Google's spp to provide OTP's. Before trying to install the integration I went to Amazon's 2FA page, disabled 2FA, removed both authenticator apps, then re-enabled 2FA and started the process of adding your app first. When it gave me the key I stopped and went to my Home Assistant instance and started the process of installing the integration. After filling out your configuration form I clicked submit and got the text box with the OTP. I then went back to the Amazon page pasted the OTP into the box and clicked submit. Amazon then opened the 2FA page showing that an authenticator app had been enrolled. I went back to the Home Assistant page and checked the box that the OTP had been successfully confirmed. It then opened an Amazon Alexa sign in page with the my email and password pre-populated. I clicked submit. It refreshed the page except it now wanted a captcha filled in. Filled in the captcha and clicked submit. Then opened a page asking for an OTP which the field was pre-populated with your original OTP. At the same time Amazon texted me an OTP. I clicked submit with the pre-populated OTP (not the one texted by Amazon). It refreshed the page with an error message "There was a problem OTP Not Valid". I changed the OTP to the one Amazon texted me and clicked sign in. It opened a page with the URL to my Home Assistant instance via Nabu Casa - The page displayed "401: Unauthorized". I went back to the Home Assistant instance the the Message Box "Open Website - This step requires you to visit an external website to be completed". I clicked "Open Website" This then opened the Amazon Alexa sign In page with my email and password pre-populated. I click submit and it refreshes the page except it wants captcha. I fill in the captcha and click submit. It then opens a page for an OTP which the field is pre-populated with your original OTP. I click submit and again there is an error "This is not a valid OTP". Amazon had texted me a new OTP. I change the value to that and click submit.
It then opens the URL to my Home Assistant instance at Nabu Casa and the page displays "Success! This window can be closed." I go back to Home Assistance and now there is a form that says "Success! Configuration created for...". I assign all the discovered devices I have many (FireTV Sticks, Echo, Dots, Fire Tablets) in their respective areas and the integration is now installed. I don't understand why your OTP doesn't work??? Why I had to use the OTP that was texted to me by Amazon to complete the installation. I also don't understand why I had to go through the login process twice before it finally completed successfully. Attached in my home-assistant.log. Note that I checked "Advanced Debugging" on your configuration form. Also note that just prior to trying to install this I upgraded the Home Assistant core to the latest version. See details below:

Core: 2021-3.2 Supervisor: 2021.03.4 OS: Home Assistant OS 5.12 Hardware: Raspberry PI 4 B 8GB home-assistant.log

alandtse commented 3 years ago

Please enable the debug logs. It's already described in the thread.

scacace commented 3 years ago

Sam...Was working prior to latest Media Player upgrade . Now nothing makes it work. Even tried the cookie.txt method, and lesser versions. Uninstall Reinstall. Keep getting the Discovered,,,..ran configure as discovered and as integration. After Text over the air authorization, the notification remains about confirming approved before Continue.. but only stays at that screen no matter how many Submits... it just does not progress on

scacace commented 3 years ago

Reinstalled HACS as there was a new integration repository that would not go away. Saw that AMP 3.8.4 was posted and reinstalled. Was able to proceed with care.. as the proxy errored from the Amazon authentication trying to refer back to my HA, but somehow was successful when I closed open windows via chrome, and got my Success page. All reappeared. My automations resumed, and survived a HA restart

divemasterjm commented 3 years ago

After updating to latest version i also get stuck on integration page

oudoulj commented 3 years ago

After updating to latest version i also get stuck on integration page

I was also stuck on the login page for a while. Ended up uninstalling the integration and removing the alexa_media: block in configuration.yaml (which will be deprecated) I created a new app on Amazon as explained here https://github.com/custom-components/alexa_media_player/wiki/Configuration#built-in-2fa-app then installed the Alexa Media Player from HACS again and it worked this time. Had to fill in my new 2FA key and my httpS duckdns url in the large AMP configuraiton modal.

martin3000 commented 3 years ago

I had to delete the AMP integration, reboot HA and reconfigure the AMP integration. then it worked.

github-actions[bot] commented 3 years ago

The issue has received no activity for 60 days and will be closed in a week.

Myskat commented 2 years ago

You still haven't posted your logs for me to review.

EDIT: This is what I need.

 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Creating new login
 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.helpers] ****@****.com: Returning uuid {'uuid': 'f11ec3b8f27dfc2ef086c6c1fcd7a9a8', 'index': 0}
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Login created for ****@****.com - amazon.in
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Attempting oauth login to https://www.amazon.com/ap/signin?openid.return_to=https://www.amazon.com/ap/maplanding&openid.assoc_handle=amzn_dp_project_dee_ios&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&pageId=amzn_dp_project_dee_ios&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:373533316563306330663263386433393532333737306536363436383335643023413249564c5635564d32573831&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.response_type=token&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_a cess&language=en_IN
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Unable to generate OTP; 2FA app key not configured
 2021-02-21 21:11:36 DEBUG (MainThread) [alexapy.alexalogin] Unable to generate OTP; 2FA app key not configured
 2021-02-21 21:11:36 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Starting proxy for ****@****.com - amazon.in
 2021-02-21 21:11:37 DEBUG (MainThread) [custom_components.alexa_media.config_flow] Found flow_id; adding 127.0.0.1 to known_ips for 300 seconds

Hello, can you indicate the source, where did you get the information on the constructor of this URL? In particular, I can't figure out where..signin comes from? .. Found either ..oauth2 .. in Cognito, or ..oa? .. in LWA. I also can't find info on ... client_id = device: 4145 ... Found either ..client_id = amzn1.application-oa2-client.b4d6 .. in LWA, or ..opn6m304vbavurl9 .. in Cognito. Thank you in advance! Hello, can you indicate the source, where did you get the information on the constructor of this URL? In particular, I can't figure out where..signin comes from? .. Found either ..oauth2 .. in Cognito, or ..oa? .. in LWA. I also can't find info on ... client_id = device: 4145 ... Found either ..client_id = amzn1.application-oa2-client.b4d6 .. in LWA, or ..opn6m304vbavurl9 .. in Cognito. Thank you in advance!

joeuser000 commented 2 months ago

i got the error in the homeassistant logs. I verified the OTP but got the "unknown error". Here is the latest attempt in the logs.

File "/config/custom_components/alexa_media/config_flow.py", line 551, in async_step_totp_register return await self.async_step_start_proxy(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/config_flow.py", line 358, in async_step_start_proxy str(URL(self.config.get(CONF_HASS_URL)).with_path(AUTH_PROXY_PATH)), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 179, in __new__ raise TypeError("Constructor parameter should be str") TypeError: Constructor parameter should be str simdo01-desktop:/config# tail 300 home-assistant.log tail: can't open '300': No such file or directory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/config_flow.py", line 551, in async_step_totp_register return await self.async_step_start_proxy(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/config_flow.py", line 358, in async_step_start_proxy str(URL(self.config.get(CONF_HASS_URL)).with_path(AUTH_PROXY_PATH)), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 179, in __new__ raise TypeError("Constructor parameter should be str") TypeError: Constructor parameter should be str

joeuser000 commented 2 months ago

Upgrade HA to 2024.7.4 and installed "patched" AMP. Got past OTP sign-in issue however AMP shows not loaded in Integrations. See error in logs.

`024-08-06 10:25:12.846 ERROR (MainThread) [homeassistant.setup] Error during setup of component alexa_media Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 404, in _async_setup_component result = await task ^^^^^^^^^^ File "/config/custom_components/alexa_media/init.py", line 128, in async_setup for account in domainconfig[CONF_ACCOUNTS]:


KeyError: 'accounts'`
joeuser000 commented 2 months ago

Upgrade HA to 2024.7.4 and installed "patched" AMP. de-installed, deleted pickle files in .storage, restarted HA. re-installed. AMP is now working.