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

Error 400: invalid_request due to Google Auth policy change #21873

Closed
andorardo opened this issue Mar 2, 2022 · 26 comments
Closed

Error 400: invalid_request due to Google Auth policy change #21873

andorardo opened this issue Mar 2, 2022 · 26 comments
Assignees

Comments

@andorardo
Copy link

Feedback

In the "Configure OAuth Consent screen" section, the documentation item 6 suggests adding a Test User. But such an option no longer exists in the Google flow. (There is no mention of a "Test User" anywhere in creating the app.)

URL

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

Version

2022.3.0

Additional information

No response

@probot-home-assistant
Copy link

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

@andorardo
Copy link
Author

By the way, I followed the instructions to a T, and get an Error 400: invalid_request at the end.

I made sure to select Desktop rather than Web app, and it still gives that error. The only deviation I had from the instructions was that I was not able to add a Test user, since that option is gone. Could that be the reason?

@allenporter
Copy link
Contributor

Hi,

I just went through the oauth consent steps and I see the test user steps and references test steps in the instructions:

Screen Shot 2022-03-02 at 7 06 11 PM

Screen Shot 2022-03-02 at 7 06 21 PM

Screen Shot 2022-03-02 at 7 06 42 PM

Once I completed, you can change the status from Testing to Production or back. The Test users option still shows up when in Testing

Screen Shot 2022-03-02 at 7 08 49 PM

Screen Shot 2022-03-02 at 7 09 21 PM

Screen Shot 2022-03-02 at 7 09 27 PM

I am not seeing what you are seeing, so either you have a different view or a step got lost somewhere?

Regarding your invalid_request error, I need more information about the details of the error if you have them since there are a couple variations.

Lastly I can offer https://www.home-assistant.io/integrations/nest/#troubleshooting if you have not seen that, though not sure it covers your specific problem.

@andorardo
Copy link
Author

andorardo commented Mar 3, 2022

Wow, this is what I saw:

Inspired by your final image, I clicked "BACK TO TESTING", and now the "Optional info" is replaced with "Testing users". There I was able to add a testing user. So I had to switch to Testing mode to be able to add the testing users, before returning to Prod mode. (NOTE: There's no way to delete the consent screen, only edit it, and I didn't realize I had to switch modes before editing.)

The second error is that even after fixing the above testing user and hitting prod, I'm seeing

The Troubleshooting page has lots of useful error cases, but not this one in particular.

Is it possible to know what Google is complaining about with regard to "doesn't comply with Google's OAuth 2.0 policy for keeping apps secure" ?

@allenporter
Copy link
Contributor

To answer your specific question I think the documentation here is relevant:
https://developers.google.com/identity/protocols/oauth2/production-readiness/policy-compliance#separate-projects-testing-production

However, i've personally never seen this happen. It implies that one of the steps may be out of whack? I'd recommend watching the video, as it shows you how to get this setup within ~18 minutes or so.

@andorardo
Copy link
Author

For good measure, I just did everything from scratch. That is to say, I created a brand new project, enabled the apis, added the oauth consent, added the credentials, added the device project_id. All for a completely new cloud project, and I'm still seeing the same 400 error.

I just watched the video and did the whole thing AGAIN, and the same error. The only difference is I put my ids in a secrets file, but surely that's not the reason.

I have several (real) cloud projects, and I have two Nest thermostats in two separate homes. Could either of those be messing with this particular project?

@andorardo
Copy link
Author

And the authentication page I'm seeing is slightly different to the one in the video: authorize your account

@zer010gic
Copy link

I am also having the same issue trying to configure the Nest Integration with the same kind of error. I have went through the setup twice now.

@zer010gic
Copy link

Here is the error I am getting as well.

Screen Shot 2022-03-02 at 10 50 31 PM

@zer010gic
Copy link

FYI I used my actual google account and not a test account.

@zer010gic
Copy link

SO I got it to work. I had to put the app back in Testing, Authorize it, get the token etc, and then set it to published.

@andorardo
Copy link
Author

That worked for me too. Bravo Corey, thanks for figuring it out!

@allenporter
Copy link
Contributor

Just a warning, this likely will mean that your credentials will expire in 7 days. I think we need to figure out the actual problem that you're hitting when in Production.

@andorardo
Copy link
Author

Thanks for the heads up! How can we debug this further?

Could there be a way in which our defaults are different and leading to a different result?

@allenporter
Copy link
Contributor

Hi, I just created a new totally new device access project and totally new cloud project and just completed setup. I was not able to reproduce this issue.

Are you setting extra options in the oauth consent flow? e.g. a logo or something? I'm out of ideas but i would look out for any extra steps in the oauth consent flow. That was also where you said the test users option was not an option.. however it was there.. so i don't follow what the problem was, but it must have been in a slightly different order. Maybe something that was missing that didn't seem like a big deal actually has some other side effects like requiring validation from Google.

@andorardo
Copy link
Author

andorardo commented Mar 3, 2022 via email

@allenporter
Copy link
Contributor

I appreciate that view, but I don't have that information. The current steps have been developed over the last year and a half and improved over 30+ documentation changes based on new feedback where people get stuck. This is a new state I've never seen before after helping 50 to 100 users of the thousands of users who have set this up, in conversations like this.

May I suggest following the pure Google developer docs and try out their curl commands? It's straight from Google documentation can take home assistant out of the picture.

So sure, probably some global setting that you have. Nest.com account? Gsuite account? Not sure...

@zer010gic
Copy link

Not sure if it helps but I migrated from Hubitat where i had this setup and did not have this issue. They use a very similar process. I had already deleted all of the Hubitat related elements from google and the smart device section before starting the workflow for Home Assistant.

@andorardo
Copy link
Author

andorardo commented Mar 3, 2022 via email

@allenporter
Copy link
Contributor

Still trying to think outside of the box on ideas here...

  • OAuth Consent screen is usually a place where issues crop up -- e.g. extra data
  • A mismatch between the Device Access Console OAuth client id and the Google Cloud console oauth client id. (e.g. every time you create a new oauth client id, it needs to be refreshed in the device access console) however it sounds like that isn't the case here if you're recreating it every time.
  • Another consideration could be multiple accounts involved (e.g. signed into one account in google cloud console and different account in device access project)
  • Here are the docs from Google: https://developers.google.com/nest/device-access/get-started for setting this up with Web Server creds -- perhaps if that still doesn't work it confirms that its a global issue, regardless of auth type.

I'm happy to try to diagnose w/ you on the home assistant discord, or go into a screen sharing session or something to compare the final states of oauth consent screens

@M1K3SD1
Copy link

M1K3SD1 commented Mar 4, 2022

Just got the same thing. Set it to testing and it worked immediately.
I want to add that I too had a very old HA project that I have removed before starting this. Not sure if it's related.

@zer010gic
Copy link

I saw an interesting suggestion to do this workflow while connected over a nabu casa https connection into the HA instance since it will then source it from a https source. I am going to try that later.

@M1K3SD1
Copy link

M1K3SD1 commented Mar 4, 2022

@zer010gic I tried that, didn't work for me.

@zer010gic
Copy link

@M1K3SD1 Correct same here. It did not work for me either.

@allenporter allenporter changed the title "Test Users" no longer an option Error 400: invalid_request due to Google Auth policy change Mar 4, 2022
@allenporter
Copy link
Contributor

I realize this issue is a documentation component issue, so we should not be using it to track issues in home assistant core.

In home-assistant/core#67662 someone found that this is due to a global oauth policy change https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#dates-oob -- we'll follow up on that home assistant issue.

@allenporter
Copy link
Contributor

I am closing this since the original test users issue was clarified, moving to the core issue.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants