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

My Home Assistant OAuth redirect fails with "Unknown Error Occurred" when not using "Keep me logged in" #73625

Closed
sidplayos2 opened this issue Jun 17, 2022 · 18 comments · Fixed by home-assistant/my.home-assistant.io#254
Assignees

Comments

@sidplayos2
Copy link

The problem

On upgrading to 2022.6.3 and attempting to re-auth the Nest Integration and successfully completing the Google steps , when returning to the integration screen from the myhomeassistant URL, am presented with "Unknown Error Occurred". Additionally adding logging to try and diagnose the issue presents no log entries in relation to the Nest components. The logging in configuration.yaml is as per below:

logger:
  default: info
  logs:
    homeassistant.components.nest: debug
    homeassistant.components.nest.climate_sdm: debug
    homeassistant.helpers.config_entry_oauth2_flow: debug
    google_nest_sdm: debug
    google_nest_sdm.device: debug
    google_nest_sdm.device_manager: debug
    google_nest_sdm.google_nest_subscriber: debug
    google_nest_sdm.event: debug
    google.cloud.pubsub_v1: debug
    google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager: debug

image
image

Further to this, after reverting to VM Snapshot 2022.3.4, modifying the Google Console redirect URL back to the 'non myhomeassistant' method via external SSL and deleting and recreating the Nest Integration the re-auth is successful. This indicates the Google config is correct.

Forum discussion here: https://community.home-assistant.io/t/nest-integration-problems/399572/14

What version of Home Assistant Core has the issue?

core-2022.6.3

What was the last working version of Home Assistant Core?

core-2022.3.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Nest

Link to integration documentation on our website

https://www.home-assistant.io/integrations/nest/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Please note that the uploaded diagnostics file is for the reverted 2022.3.4 successful re-auth and NOT the 2022.6.3 as the integration can't be configured (and hence there is no "Diagnostics Download" in it's menu.

In order to diagnose the issue we will need to get the logging for Nest Integration working firstly under 2022.6.3 as currently there is no logs about Nest.

@probot-home-assistant
Copy link

nest documentation
nest source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @allenporter, mind taking a look at this issue as it has been labeled with an integration (nest) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@allenporter
Copy link
Contributor

Hi,
Thanks appreciate the detailed report.

The main change here is the My Home Assistant redirect url stuff (nothing about nest specifically as far as I know).

One thing that would be helpful to know is if disabling my home assistant integration solves this. This integration is enabled in default_config

Is this something you'd be willing/able to help exercise? Your report here is much more helpful than that discussion thread, so want to take advantage of that but realize it requires a bit more from you..

(Also generally curious why you needed to reauth in the first place, but that's beside the point...)

@sidplayos2
Copy link
Author

sidplayos2 commented Jun 17, 2022

I personally suspect you are correct and it is not the Nest component specifically, more about how it interacts with the myhomeassistant.

I'll go away and get this configured and come back soon. I'm guessing once I have disabled the myhomeassistant I will need to put back the old style callback URL?

As for why I did the reauth, just my nature to check things again after a big change. Know it's not necessary, but after a core change I re-auth all my cloud/local components to make sure nothing is broken.

I am curious why the logging doesn't work but again suspect thats some other component not playing nicely.

Will come back with results soon.

@sidplayos2
Copy link
Author

So still on 2022.6.3 , removed the myhomeassistant and modified the callback URL in Google console and viola, it works.
Getting camera feeds now. Still not seeing logging around the auth process though, just this at the very end:

2022-06-18 10:02:57 INFO (MainThread) [homeassistant.components.nest.config_flow] Successfully authenticated

image

Regarding the actual myhomeassistant issue, do I need to log an issue against a different component? Great that it's working for myself, but how do we go about getting this fixed for everyone?

@probot-home-assistant
Copy link

myio documentation
myio source
(message by IssueLinks)

@probot-home-assistant
Copy link

my documentation
my source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (my) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@allenporter
Copy link
Contributor

Yeah, we should track this to find the root issue.

One other idea: Can you show what is happening in the javascript device console in the browser? Curious if there are any errors or specific failed error pages.

@sidplayos2
Copy link
Author

I can't seem to see any issues regarding the web debug console. I have tried Chrome, Edge and Firefox all with the same result and no fatal console errors that are noteworthy.

Is there a way to turn on some debugging for the myhomeassistant URL redirect bit? I'm guessing the error is either something to do with that, or maybe when it reloads the integrations/UI as it comes back from the redirect? Really odd that there is no obvious errors in the logs.

Let me know what we can try next.

image

@allenporter
Copy link
Contributor

allenporter commented Jun 18, 2022

  • When logging into home assistant do you det the "keep me logged in" setting?
  • The Network tab may show details about the redirects happening between my home assistant and your instance, but likely it will leak auth credentials so don't want them posted here... maybe trying to reproduce myself is a better route...

@sidplayos2
Copy link
Author

sidplayos2 commented Jun 19, 2022

You were right on the money with the "Keep me logged in setting", I usually never tick that box (I prefer to manually login).

However this time as a test I selected that check box on login, configured the nest component via myhomeassistant , ensuring that the myhomeassistant url was configured in google console as well and the setup was sucessful.

So it seems that provided you check that box then the myhomeassistant redirect method can work as well. Not sure if that is a bug with the myhomeassistant URL redirect or as per design. If it is required I missed any instructions relating to selecting that box.

Just to ensure this is the case, I cleared out the browser remembered passwords/cache and the issue comes back. Select the box again and it works immediately.

Using the old method with the external URL and the my: component disabled doesn't require the check box to be selected.

@allenporter
Copy link
Contributor

This was the same as #72810 (comment) for a different integration. Identified by @guyke01

i am not sure of the details about how that checkbox works, but i think it must have something to do with authentication sticking in the browser window vs setting a cookie that works when the redirect happens in another tab.

I am going to rename this issue to be related to the My Home Assistant integration and OAuth redirect.

@allenporter allenporter changed the title Nest integration re-auth fails with "Unknown Error Occurred" My Home Assistant OAuth redirect fails with "Unknown Error Occurred" when not using "Keep me logged in" Jun 19, 2022
@smarterplace
Copy link

Reading @sidplayos2 comment above, I tried logout and log back in HA (clicked on the checkbox for remember). And then I tried the integration and it worked!

@sidplayos2
Copy link
Author

That's great we think we know what it might be now. Let me know if we need to do any more test cases (even if that involves different integrations etc).

@dietpopx
Copy link

This was the same as #72810 (comment) for a different integration. Identified by @guyke01

i am not sure of the details about how that checkbox works, but i think it must have something to do with authentication sticking in the browser window vs setting a cookie that works when the redirect happens in another tab.

I am going to rename this issue to be related to the My Home Assistant integration and OAuth redirect.

just found this thread. i kept that checkbox checked, but i have a local DNS for my VMs and other things.

if i started my nest integration through http://ha:8123 -- my local dns entry, when i got to the redirect part that took me to http://homeassistant.local:8123/, it would not work regardless of having auto logon enabled and that function actually working.

when i went to http://homeassistant.local:8123/ and then started the nest integration, it works.

regardless.. thanks for the integration support.

@allenporter
Copy link
Contributor

These are the two solutions so far:

Make the sure url at my home assistant matches the url you use to access home assistant.

Check keep me signed in when logging in to home assistant

@barnes-dev
Copy link

I am now having the same issues.
I tried updating my Auth to Web Client - No Help
I deleted my Nest integration and updated the config file
After a reboot of Homeassistant I now get the add new integration for Nest - No Help
I tried to log into homeassistant.local:8123 then add the integration - No Help
I tried selecting the keep me signed in - No help

No matter what I do I get the go back logo. I am running the following update
It worked prior to this update

Home Assistant 2022.7.0b0
Supervisor 2022.06.2
Operating System 8.2
Translation Error: The intl string context variable "type" was not provided to the string "Frontend {version} - {type}"

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

Successfully merging a pull request may close this issue.

5 participants