Google sign-in stops with 'Error 400: invalid_request'
Error 400: invalid_requestShort answer
Google returns invalid_request when the request itself is not acceptable: a malformed request, a missing parameter, an unsupported method, a deprecated out-of-band redirect, or a sign-in shown in an embedded browser. If only some client IDs fail, compare their redirect URI and flow.
Fix it fast
1Find out which cause you have
Copy the full authorization URL your app opens and read its parameters: client_id, redirect_uri, response_type, scope. Compare it with a client ID that works.
python3 -c "import sys,urllib.parse as u; print(u.parse_qs(u.urlparse(sys.argv[1]).query))" 'PASTE_AUTH_URL'2Match what you see, then jump to its fix
- 1
redirect_uri is urn:ietf:wg:oauth:2.0:oob (or the code is copied by hand from a page)The app still uses the out-of-band redirectFix - 2
The error appears only inside your own app's built-in browserThe sign-in opens inside an embedded browser or WebViewFix - 3
The authorization URL lacks client_id, redirect_uri, response_type or scope, or is not URL-encodedA parameter is missing, malformed or not supportedFix
- 1
What does the error look like?
Error 400: invalid_request
Cause 1 of 3
The app still uses the out-of-band redirect
1Check
Google deprecated the out-of-band flow for all app types. Clients created before 28 Feb 2022 were blocked from 3 Oct 2022, and every remaining client from 31 Jan 2023. That is why an old client and a new one in the same project can behave differently. The page says it applies to apps in production status.
grep -rn 'urn:ietf:wg:oauth:2.0:oob' .2Fix
Move to a supported flow: the loopback IP flow for desktop apps, Google's sign-in SDKs for Android and iOS, or a server-side redirect URI for web apps.
# desktop app: register a Desktop client and use a loopback redirect
redirect_uri=http://127.0.0.1:PORT3Verify
Open the authorization URL again; the consent screen should appear.
# browser: consent screen loads without Error 400Confirmed by developers.google.com
Cause 2 of 3
The sign-in opens inside an embedded browser or WebView
1Check
Google's policy forbids sending an authorization request to an embedded user-agent under the developer's control.
grep -rn -i 'webview' .2Fix
Open the system browser (or Custom Tabs on Android) for the authorization request and receive the result through the redirect.
# open the authorization URL in the system browser instead of a WebView3Verify
Sign in from the system browser; the error no longer shows.
# manual sign-in testConfirmed by developers.google.com
Cause 3 of 3
A parameter is missing, malformed or not supported
1Check
Google lists invalid_request as: improperly formatted request, missing required parameters, or an unsupported authorization method. Print the parameters (first step) and compare with a working client.
python3 -c "import sys,urllib.parse as u; print(u.parse_qs(u.urlparse(sys.argv[1]).query))" 'PASTE_AUTH_URL'2Fix
Build the URL with Google's client library, or fix the missing or encoded parameter. Use the client type that matches the flow: a Desktop app client for the installed-app flow.
# let the library build the URL, for example google-auth-oauthlib's flow.authorization_url()3Verify
The consent screen loads for this client ID too.
# browser checkConfirmed by developers.google.com
How do I stop it coming back?
- Use Google's current client libraries for each platform, so the flow and parameters stay valid.
- Register one client per platform with the matching type (Web, Desktop, Android, iOS).
- Never run sign-in inside a WebView.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Security
Entra ID token request fails: the request body must contain the parameter 'grant_type'
AADSTS900144: The request body must contain the following parameter: 'grant_type'.
The token endpoint did not find grant_type in the form body of your POST.
3 causes, each with a fixSecurity
Angular HttpClient does not add the X-XSRF-TOKEN header to a request
403 Forbidden on POST, PUT or DELETE while GET works
Angular copies the XSRF-TOKEN cookie into an X-XSRF-TOKEN header only for mutating requests to the same origin, and only when the cookie is readable by script.
5 causes, each with a fixSecurity
An [Authorize] endpoint rejects a request with a bearer token
Authorization Header sent: no Bearer token sent.
An [Authorize] endpoint without a policy name requires an authenticated user.
4 causes, each with a fixSecurity
ASP.NET Core API rejects an Angular user's token: the signature key was not found
401 Unauthorized
The API looked for the key named by the token's kid in the key set it downloaded from your Authority, and the key was not there.
4 causes, each with a fixSecurity
ASP.NET Core rejects the token before checking it: IDX12741, three segments expected
401 Unauthorized
IDX12741 means the string the API pulled out of the Authorization header is not shaped like a JWT: a signed token has three dot-separated parts and an encrypted one has five.
3 causes, each with a fixSecurity
A Microsoft Entra access token shows Invalid Signature when you check it yourself
Tokens that a Microsoft API receives might not always be a JWT that can be decoded
A token issued for Microsoft Graph is not meant for you to validate, so a failed signature check is expected.
2 causes, each with a fix