Help for owners
Staff cannot sign in to my app with their Google Workspace accounts
Short answer
Google says the hd setting that limits sign-in to a company domain is only a display hint, and that the server must check the hd claim in the signed ID token. Most failures come from that check, a redirect address that does not match, an unverified app screen, or an admin policy.
Does this sound like your situation?
- Some staff can sign in with Google and others get an error.
- People with personal Gmail accounts can get into the app, and I want only my company.
- Google shows a warning that the app is not verified.
- The error mentions a redirect address that does not match.
- Sign-in worked until the app moved to a new web address.
Why does this happen?
The domain limit is only a hint
Google states that the hd request parameter only optimises the account picker for a domain, and warns not to rely on it to control who can access your app, because client-side requests can be modified. A sign-in that only sets the hint will let other accounts through.
Confirmed by developers.google.com
The server does not check the hd claim
Google states that you must check the hd claim of the ID token when restricting access to members of certain domains, and that the claim is absent when the account does not belong to a Google-hosted domain. It also says not to identify organization users by the domain of their email address.
Confirmed by developers.google.com
The redirect address does not match
Google compares the address your app sends users back to with the list registered for the app. A new domain, a missing slash or http instead of https gives a mismatch error.
Technical detail: Google sign-in stops with Error 400: redirect_uri_mismatch
The app shows as unverified
An app that asks for sensitive access and has not been through Google's verification shows a warning screen, and some staff stop there.
Technical detail: Users see the unverified app warning on Google sign-in
An administrator restricted the app
A Workspace admin can restrict which apps may access company accounts. Google lists an admin policy as a reason a login can stop working, returning the error admin_policy_enforced.
Confirmed by developers.google.com
What can I do about it today?
- Copy the exact error and who sees itNote whether it is everyone or certain people, whether they are on the company domain, and the error text on screen.
- Ask an admin whether the app was blockedA Workspace admin can check the Admin console for restrictions on the app and for recent changes.
- Check what changedA new web address, a new server, a changed Google Cloud project or a staff account that was renamed.
- Do not weaken the domain rule to get people inOpening sign-in to any Google account lets outsiders reach your data.
- Send the notes to your developerInclude screenshots of the error and the web address shown in the browser at that moment.
When should I bring someone in?
- The app must be limited to your company and you are not sure it is.
- Sign-in fails for everyone after a move or a change in Google Cloud.
- You need single sign-on across several apps, not only one.
How do I handle it?
- Reproduce with a staff and an outside accountI try one company account and one personal account, and read the exact response each gets.
- Check the app's registrationI compare the registered redirect addresses, consent screen and verification state with what the live app uses.
- Move the domain check to the serverThe server validates the signed ID token and checks the hd claim, instead of trusting the picker hint.
- Test on a staging copy firstChanges to sign-in are tried on a test copy so staff are not locked out.
- Leave a written noteYou get a short note of the registered addresses and who owns the Google Cloud project.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
Is setting the company domain enough to keep outsiders out?
No. Google states the domain setting is only a user interface optimisation and that the server must check the hd claim in the signed token.
Why do personal Gmail users have no hd claim?
Google states the claim appears only if the user belongs to a Google Workspace or Cloud organization, and its absence means the account is not on a Google-hosted domain.
Can I sign in with Microsoft accounts instead?
That is a separate setup, covered on the page about Microsoft 365 single sign-on for a web app.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.