Skip to content

Why Google Sign-In fails in Android WebView (Error 403: disallowed_useragent) and how to fix it

Your website opens cleanly inside an Android WebView APK—until a user taps “Continue with Google” and hits Google’s red Error 403: disallowed_useragent screen. Here is why that happens and the four real ways to solve it without fragile hacks.

What actually failed

Embedded WebViews cannot isolate credentials from the host app

When a website loads inside an embedded WebView, the containing Android app can inspect network traffic, inject JavaScript, and read form fields. To protect user accounts from phishing and credential interception, IETF RFC 8252 mandates that OAuth flows run in an external system browser or out-of-process browser tab (such as Chrome Custom Tabs), not an embedded WebView.

Google enforces this strictly on accounts.google.com. That is why the exact same login button works in mobile Chrome, works in a Chrome-installed PWA, and fails immediately inside a WebView APK.

Choose the right fix

Four reliable ways to resolve WebView login

Pick the approach that matches whether you control the native Android code or only control your website.

ApproachWebView compatibilityEngineering scopePractical trade-off
1. Email + password or 6-digit email OTPYes (works in WebToApp APKs)No — website change onlyFastest fix for WebView APKs. Users type an email/code instead of tapping a Google button.
2. Chrome Custom Tabs + deep link callbackRequires native Android shell (RFC 8252)Yes — AndroidManifest intent filter + AppAuth/CustomTabsCompliant with Google OAuth rules, but requires custom native code and careful cookie/session handoff back into the app.
3. Native Google Sign-In / Credential Manager SDKRequires native SDK + JS bridgeYes — native OAuth client, SHA-1 fingerprint & backend ID-token checkBest native UX for store apps; requires both app-side SDK setup and backend token verification (see Appilix / Median docs).
4. Installable Chrome PWA (or TWA)Runs in Chrome, not embedded WebViewManifest + Service Worker (plus assetlinks.json for TWA)Google Sign-In works normally because Chrome is a compliant system user agent, with zero WebView OAuth block.

Do not use this shortcut

Why spoofing User-Agent is a trap

Older forum posts recommend stripping ; wv from the Android WebView User-Agent header so Google thinks the request comes from desktop or mobile Chrome. Treat that as broken in production:

  • Google checks more than a single header and updates enforcement without notice—your app can lose sign-in overnight.
  • WebAuthn passkeys, Android autofill and hardware security keys do not share the system browser session inside an embedded WebView.
  • If you later submit to Google Play or pass a security review, circumventing OAuth user-agent protections creates compliance risk.

Useful pattern for web teams

Detect WebView cleanly and show a working login method

If your website serves both regular browsers and a WebView APK, keep Google Sign-In for regular browser visitors and highlight email/OTP sign-in when an embedded Android WebView is detected (always keeping email login available as a fallback regardless of detection):

// Keep email/OTP login always reachable;
// optionally de-emphasize Google OAuth inside Android WebView.
const isAndroidWebView =
  /Android/.test(navigator.userAgent) &&
  /; wv\)/.test(navigator.userAgent);

Note: user-agent detection is only a UI hint to guide users toward your working email/OTP flow—never use it for security decisions.

Verify on a real phone

Five-step login acceptance test before distributing your APK

  1. Cold start signed out: install the APK fresh, open a private page, and confirm the app routes to a working login screen (email/password or 6-digit OTP).
  2. Cancel halfway: dismiss or tap Back during login and verify the user does not get trapped in an infinite redirect loop.
  3. Destination return: after signing in, confirm the user lands on the intended page rather than losing context on the homepage.
  4. App restart persistence: force-close the APK and reopen it to verify your session cookie survives restarts (check SameSite and Secure cookie flags).
  5. Session expiry: revoke the session server-side, tap an action inside the app, and confirm re-authentication works cleanly.

WebToApp boundary: WebToApp builds a clean signed Android WebView APK without injecting proprietary native auth SDKs. If native Google Sign-In inside an installed app is a hard requirement, compare WebToApp vs Appilix (bridge + backend ID-token setup) or WebToApp vs PWABuilder (Chrome Trusted Web Activity).

Test your real login flow in a free Android APK

Do not guess from a desktop preview. Every WebToApp account includes one free successful Android APK build so you can verify sign-in, cookies and back navigation on an actual phone.

Build a free test APK

FAQ

WebView Google Sign-In questions

Why does Google show Error 403: disallowed_useragent inside my WebView APK?

Google blocks its OAuth 2.0 authorization screens inside embedded WebViews in accordance with RFC 8252 (OAuth 2.0 for Native Apps). Because the host app controls the WebView DOM and JavaScript context, embedded sign-in cannot guarantee that credentials are isolated from the host app.

Can I fix disallowed_useragent by changing the WebView User-Agent string?

You should not rely on User-Agent spoofing. Even when a spoofed string temporarily bypasses a check, Google periodically updates detection, passkeys and 2FA hardware prompts fail inside WebViews, and login can break silently for existing users without warning.

Which login methods work reliably inside a WebView APK without native code?

Email and password forms, 6-digit email OTP codes, and same-origin session cookies work inside Android WebView APKs. Magic links also work if the user pastes a code or opens the verification link directly inside the app rather than bouncing into an external browser session.

How do native Android apps implement Google Sign-In properly?

Native apps either launch Chrome Custom Tabs (an out-of-process system browser tab using AppAuth / RFC 8252 with a registered App Link or custom scheme redirect) or use Android Credential Manager / Google Identity Services to obtain an ID token and verify it on the backend.

Does WebToApp include a native Google Sign-In bridge?

No. WebToApp packages your web content into a standard signed Android WebView APK and does not inject a native OAuth SDK or Custom Tabs bridge. If your site requires Google Sign-In, enable email/OTP login for APK users, distribute your site as an installed Chrome PWA, or evaluate a native-bridge builder.

Why do I stay logged out even after a non-Google login succeeds?

Check three things: cookies marked SameSite=None without Secure over HTTPS, third-party identity domains blocked by WebView cookie partitioning, or a missing return-path parameter that redirects back to / instead of the private page.