1.1.0 • Published 7 months ago

google-oauth-webview v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Google OAuth Webview

Google OAuth fails in some webviews (in-app browsers) and displays a 403 disallowed_useragent error message. This library detects whether the user is in a webview that is not supported by Google OAuth.

Installation

npm install google-oauth-webview

Usage

import {
  isWebviewUnsupportedByGoogleOAuth,
  getWebviewOwner,
  WebviewOwner,
} from "google-oauth-webview";

// Checks if the user agent is a user agent of a web view that is not supported by Google OAuth.
const isSupported: boolean = isWebviewUnsupportedByGoogleOAuth(
  navigator.userAgent
);

// When possible, determines the owner of the webview based on the user agent.
// If the user agent does not match a webview or the webview owner cannot be determined, returns null.
const webviewOwner: WebviewOwner = getWebviewOwner(navigator.userAgent);

Sponsor

Linito logo

Browsers and applications tested

Legend

  • ✅ The application or browser has been tested and its user agent is present in the test.
  • ❌ The application or browser has NOT been tested.

Browsers tested

BrowserMac OSWindowsiOSAndroid
Chrome
Firefox
Edge
Safari
Samsung Internet
Opera

Applications tested

ApplicationiOSAndroidUses a webviewGoogle OAuth works in webview
WhatsAppno-
ProtonMailno-
Telegramyesyes
Gmailyesyes
Slackyesyes
Facebook Messengeryesno
X / Twitteryesyes
LinkedInyesno
reddityesyes
YouTubeyesyes 
Discordyesyes
Facebook Appyesno
Instagramyesno

Applications that still need to be tested

ApplicationiOSAndroid
TikTok
Snapshat

Contributing

  1. Connect your cell phone to your local network (e.g. wifi).
  2. Clone this repository and run npm run serve. This command will serve a web page on your local network, displaying the user agent. Copy the network URL displayed in the terminal.
  3. Paste the URL into your application (for example, if you're testing a messaging application, you can send the URL to yourself as a message).
  4. Click on the URL in your application and check whether the page is loaded in a web view or in the native browser. If the URL link doesn't work because it's an IP address, you can use the URL https://www.google.com/url?q=<your-local-URL> instead, which should do the trick.
  5. Copy and paste the user agent displayed in the src/user-agents.ts file.
  6. Test whether Google OAuth works in the webview. If not, update the library code and tests accordingly.
  7. Complete the README.

Rules

  • DO NOT copy and paste user agents found on forums, etc.
  • DO NOT copy and paste user agents returned by ChatGPT or other artificial intelligence platforms.

We want accurate data that has been tested on real devices with real applications.

Supported Node and TypeScript versions

 Node min versionsTS min version
20, 225.6
1.1.0

7 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago