home-assistant / developers.home-assistant

Developers website for Home Assistant.
https://developers.home-assistant.io
Other
296 stars 934 forks source link

Devcontainer stuck after onboarding #1756

Open carlosjourdan opened 1 year ago

carlosjourdan commented 1 year ago

I've followed the steps on https://github.com/home-assistant/devcontainer to start home assistant from VS Code in a Windows 10 machine.

After supervisor starts, I can access HA on http://localhost:7123. However, after filling the onboarding forms, I get to a screen were I can only see the Home Assitant logo and the background animation. Reloading the page prompts for the user and password, but if I enter the correct credentials I get redirected once again to onboarding.html with only the logo.

I see no errors on supervisor logs, and no javascript errors on the console.

Any thoughts on how to resolve this?

malkstar commented 1 year ago

FYI I got past this issue by commenting these two lines out (not really a fix, but let's you get on with it)

https://github.com/home-assistant/core/blob/dev/homeassistant/components/frontend/__init__.py#L576-L577

rpimeekle commented 1 year ago

There is a bit of discussion around this in the Home Assistant discord group, see: Devs_add-ons: Addon Development thread.

Seems like a recent core change might have broken the way the integration aspect of the onboarding is loaded/authenticated. Timmehhh on discord worked out that the /api/onboarding response returns: [{"step":"user","done":true},{"step":"core_config","done":true},{"step":"analytics","done":true},{"step":"integration","done":false}] As such, he pointed out that another workaround is to go into the developer console and resend the auth_token to the onboarding/integration endpoint.

(See the discord chat here for Firefox inspector method, or here for Chrome developer console request).

rpimeekle commented 1 year ago

A workaround in Chrome: in the Network tab of the Chrome developer console, when you're stuck on onboarding page (after setting up your password and Home location and analytics selections), find the onboarding request (with the little cog next to it). Right click, and select Copy > Copy as fetch. Alternatively, you should be able to use the fetch below. I just used it on Windows, which might mean that using it on Linux or something else will need a different sec-ch-ua-platform value.

Once you have all your details in the fetch, as below, paste it into the console in your Chrome developer console.

Network tab >> onboarding >> right-click >> Copy > Copy as fetch

fetch("http://localhost:7123/api/onboarding/integration", {
  "headers": {
    "accept": "*/*",
    "accept-language": "en-AU,en;q=0.9,sv-SE;q=0.8,sv;q=0.7,en-GB;q=0.6,en-US;q=0.5",
    "sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "Authorization": "Bearer {access_token}"
  },
  "body": '{"client_id": "http://localhost:7123/", "redirect_uri": "http://localhost:7123/?auth_callback=1"}',
  "method": "POST"
});

Get {access_token} in the fetch above from the Developer Console:

Network tab >> token >> Preview tab >>access_token: eyJh...[really long string here]...0TBPI