joeyhage / homebridge-alexa-smarthome

Connect Alexa devices to HomeKit
MIT License
81 stars 20 forks source link

Cookie not saved #134

Open Praecursor opened 3 months ago

Praecursor commented 3 months ago

Cookie is successfully created. Authentication successful, Browser: "Amazon Alexa Cookie successfully retrieved. You can close the browser." Then the birdge restarts, and after restart its again: "Failed to initialize connection to Alexa. - Please open http://192.168.....:8585/ with your browser and login to Amazon. The cookie will be output here after successfull login."

Logs:

18.6.2024, 12:46:45Alexa Bridge starting 18.6.2024, 12:46:54Alexa BridgeLoaded plugin 'homebridge-alexa-smarthome' 18.6.2024, 12:46:54Alexa BridgeLoading 2 platforms... 18.6.2024, 12:46:54Alexa BridgeHomebridgeAlexaSmartHomeLogin required because existing authentication not found 18.6.2024, 12:46:54Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: No cookie given, generate one 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Error from retrieving cookies 18.6.2024, 12:46:55Alexa BridgeBridge is running on port 51846. 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeFEHLERFailed to initialize connection to Alexa. - Please open http://192.168.xxx.xx:8585/ with your browser and login to Amazon. The cookie will be output here after successfull login. 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Authentication check Error, try re-init 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: No cookie given, generate one 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Error from retrieving cookies 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Authentication check Error and renew unsuccessful. STOP 18.6.2024, 12:46:55Alexa BridgeHomebridgeAlexaSmartHomeFEHLERAfter initialization - HttpError(Error getting smart home devices. Reason: Cookie invalid, Renew unsuccessful) 18.6.2024, 12:47:08Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: MODIFIED Response Body to rewrite URLs 18.6.2024, 12:47:15Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Handle token registration Start: {"loginCookie":"session-id=... 18.6.2024, 12:47:15Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Register App 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Response (200) 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Register App Response: {"response":{"success":{"extensions":{"device_info":{"device_name":"... Bridge","device_serial_number":"...","device_type":"..."},"customer_info":{"account_pool":"Amazon","user... 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Update Cookie x-main = "....?rlEATmafG" 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Update Cookie at-main = "Atza|....-QTTSXGB_uumY-RLiT....gmFlrBQKCJyK5gX7tkZ" 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Update Cookie sess-at-main = "..../7mVdnwaJcb6cMIBN4=" 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Register capabilities 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Response (204) 18.6.2024, 12:47:16Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Get User data 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Response (200) 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Get User data Response: {"countryOfResidence":"DE","effectiveMarketPlaceId":"....","email":"....@me.com","eulaAcceptance":true,"features":["ALEXA_HANDS_FREE_FEATURE_GATING_OCTO8_TMO","ALEXA_AUTO_ANDROID_STANDALONE_MODE_ENABLED","ALEX... 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie csrf = 109139941 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Exchange tokens for amazon.de 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Response (200) 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Exchange Token Response: {"response":{"tokens":{"cookies":{".amazon.de":[{"Path":"/","Secure":true,"Value":"....-3738614-.....","Expires":"13 Jun 2044 10:47:17 GMT","HttpOnly":false,"Name":"session-id"},{"Path":"/","Secure":true,"Value":"257-6539020... 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie session-id = 259-4230241-2085638 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie session-id-time = 2349427637l 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Update Cookie session-id = 257-3738614-3153841 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie ubid-acbde = 257-6539020-1256743 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie x-acbde = "....@fSGA8fwMlmML" 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie at-acbde = ".....ZUaYxL0Ep1f6V" 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie sess-at-acbde = ".....=" 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Step 4: get CSRF via /api/language 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Response (200) 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Add Cookie csrf = 34310470 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Cookie: Result: csrf=34310470, Cookie=session-id=...-....-....; session-id-time=2349427637l; ubid-acbde=257-6539020-1256743; x-acbde=....; sess-at-acbde=.....=; csrf=34310470 18.6.2024, 12:47:17Alexa BridgeHomebridgeAlexaSmartHomeAlexa login cookie updated. Storing cookie in file: /var/lib/hoobs/alexabridge/persist/.homebridge-alexa-smarthome 18.6.2024, 12:47:28Alexa Bridge starting 18.6.2024, 12:47:35Alexa BridgeLoaded plugin 'homebridge-alexa-smarthome' 18.6.2024, 12:47:35Alexa BridgeLoading 2 platforms... 18.6.2024, 12:47:36Alexa BridgeHomebridgeAlexaSmartHomeLogin required because existing authentication not found 18.6.2024, 12:47:36Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: No cookie given, generate one 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Error from retrieving cookies 18.6.2024, 12:47:37Alexa BridgeBridge is running on port 51846. 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeFEHLERFailed to initialize connection to Alexa. - Please open http://192.168.192.69:8585/ with your browser and login to Amazon. The cookie will be output here after successfull login. 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Authentication check Error, try re-init 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: No cookie given, generate one 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Error from retrieving cookies 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeAlexa-Remote: Authentication check Error and renew unsuccessful. STOP 18.6.2024, 12:47:37Alexa BridgeHomebridgeAlexaSmartHomeFEHLERAfter initialization - HttpError(Error getting smart home devices. Reason: Cookie invalid, Renew unsuccessful)

Plugin Config:

{ "accessories": [], "platforms": [ { "platform": "Alexa", "name": "Alexa", "routines": false, "door": false, "blind": false }, { "platform": "HomebridgeAlexaSmartHome", "amazonDomain": "amazon.de", "auth": { "refreshInterval": 4, "proxy": { "clientHost": "192.168.xxx.xx", "port": 8585 } }, "language": "en-US", "debug": true } ] }

Screenshots:

Environment:

joeyhage commented 1 month ago

Do you use Hoobs or Homebridge? This seems similar to other reported issues when using Hoobs. Hoobs is not supported by this plugin

wheeler01 commented 1 month ago

I am running Homebridge 1.8.4. I upgraded from plugin ver. 2.2.0 to 2.2.1 (I did try to go back but, error still exists) this morning. After doing so I am receiving the following errors (which I suspect are related to this issue):

[14/08/2024, 14:06:47] [homebridge-alexa-smarthome] Failed to initialize connection to Alexa. - Please open http://localhost:8840/ with your browser and login to Amazon. The cookie will be output here after successfull login. [14/08/2024, 14:06:47] [homebridge-alexa-smarthome] After initialization - HttpError(Error getting smart home devices. Reason: Cookie invalid, Renew unsuccessful)

I did visit the url shown in the error, but was only given a screen to install the Alexa app.

Any assistance would be greatly appreciated. Thank you.

joeyhage commented 1 month ago

@wheeler01 when you access Homebridge from your browser, what is the full URL you use?

For example, I access Homebridge by visiting homebridge-vm.local:8581 so instead of localhost:8840, I go to homebridge-vm.local:8840.

The same applies if you use an IP address to access homebridge. Homebridge 192.168.1.100:8581 to login to Homebridge then replace the Amazon suggested localhost with the same IP

joeyhage commented 1 month ago

I forgot to mention, I would recommend following the docs here (https://github.com/joeyhage/homebridge-alexa-smarthome?tab=readme-ov-file#initial-configuration) to set the clientHost to the IP address instead of localhost.

wheeler01 commented 1 month ago

I took your advice and changed the hostname to homebridge.local as you'll see below

[14/08/2024, 19:06:53] [homebridge-alexa-smarthome] Failed to initialize connection to Alexa. - Please open http://homebridge.local:8840/ with your browser and login to Amazon. The cookie will be output here after successfull login. [14/08/2024, 19:06:53] [homebridge-alexa-smarthome] After initialization - HttpError(Error getting smart home devices. Reason: Cookie invalid, Renew unsuccessful)

When I visit homebridge.local:8840 with a web browser here's what I see:

image

There is no option to log in so i am confused as to what I need to do.

joeyhage commented 1 month ago

I took your advice and changed the hostname to homebridge.local as you'll see below

[14/08/2024, 19:06:53] [homebridge-alexa-smarthome] Failed to initialize connection to Alexa. - Please open http://homebridge.local:8840/ with your browser and login to Amazon. The cookie will be output here after successfull login. [14/08/2024, 19:06:53] [homebridge-alexa-smarthome] After initialization - HttpError(Error getting smart home devices. Reason: Cookie invalid, Renew unsuccessful)

When I visit homebridge.local:8840 with a web browser here's what I see:

image

There is no option to log in so i am confused as to what I need to do.

Without changing the config, does it do anything different if you visit the IP address of your computer on port 8840?

Example: http://192.168.1.100:8840

I deleted my cookie and was able to get a new one yesterday evening without issue when using the latest version. Mine went straight to the Alexa login screen. The URL in the browser seems to make a difference for some reason (I am not the developer of the Amazon cookie code)

wheeler01 commented 1 month ago

There is no change between using the hostname of homebridge.local or 10.0.7.4 (the local LAN IP of my Homebridge Box) on port 8840. When you say you deleted your cookie last night, do you mean from your web browser or from your homebridge box? If from your homebridge box, how do you do that? If you don't mind me asking.

wheeler01 commented 1 month ago

I hope you don't think I am asking a stupid question, but I have dropped my browser cookies and cache data and still experiencing the same issue. That's why I asked which cookie you deleted and how.

wheeler01 commented 1 month ago

I ended figuring out what i was doing wrong. in this case it truly was user error. My bad. Thanks for the help. Awesome plugin.

kolutshan commented 1 month ago

Could you provide what your user error was? I'm facing the same issue and can't figure out what I'm doing wrong. Thanks!