Chrome Apps - User Authentication [Deprecated] - Chrome Developers (2024)

Caution

Important: Chrome will be removing support for Chrome Apps on all platforms. Chrome browser and the Chrome Web Store will continue to support extensions. Read the announcement and learn more about migrating your app.

Web authentication protocols utilize HTTP features, but Chrome Apps run inside the app container; they don't load over HTTP and can't perform redirects or set cookies.

Use the Chrome Identity API to authenticate users: the getAuthToken for users logged into their Google Account and the launchWebAuthFlow for users logged into a non-Google account. If your app uses its own server to authenticate users, you will need to use the latter.

API Samples: Want to play with the code? Check out these samples, in particular the identity sample.

# How it works

Chrome Apps users have a Google account associated with their profile. Apps can get OAuth2 tokens for these users using the getAuthToken API.

Apps that want to perform authentication with non-Google identity providers must call launchWebAuthFlow. This method uses a browser pop-up to show the provider pages and captures redirects to the specific URL patterns. The redirect URLs are passed to the app and the app extracts the token from the URL.

# Google account authentication

Here are the five steps you need to complete:

  1. Add permissions to your manifest and upload your app.
  2. Copy key in the installed manifest.json to your source manifest, so that your application ID will stay constant during development.
  3. Get an OAuth2 client ID for your Chrome App.
  4. Update your manifest to include the client ID and scopes.
  5. Get the authentication token.

# Add permissions and upload app

You need to make sure the identity permission is in your manifest. You can then upload your app to the apps and extensions management page (see Publish).

"permissions": [
"identity"
]

# Copy key to your manifest

When you register your application in the Google OAuth console, you'll provide your application's ID, which will be checked during token requests. Therefore it's important to have a consistent application ID during development.

To keep your application ID constant, you need to copy the key in the installed manifest.json to your source manifest. It's not the most graceful task, but here's how it goes:

  1. Go to your user data directory. Example on MacOs: ~/Library/Application\ Support/Google/Chrome/Default/Extensions
  2. List the installed apps and extensions and match your app ID on the apps and extensions management page to the same ID here.
  3. Go to the installed app directory (this will be a version within the app ID). Open the installed manifest.json (pico is a quick way to open the file).
  4. Copy the "key" in the installed manifest.json and paste it into your app's source manifest file.

# Get your OAuth2 client ID

You need to register your app in the Google APIs Console to get the client ID:

  1. Login to the Google APIs Console using the same Google account used to upload your app to the Chrome Web Store.
  2. Create a new project by expanding the drop-down menu in the top-left corner and selecting the Create... menu item.
  3. Once created and named, go to the "Services" navigation menu item and turn on any Google services your app needs.
  4. Go to the "API Access" navigation menu item and click on the Create an OAuth 2.0 client ID... blue button.
  5. Enter the requested branding information, select the Installed application type.
  6. Select Chrome Application and enter your application ID (same ID displayed in the apps and extensions management page).

Warning

Warning: If the app ID here does not match your app ID, an error will occur when your app calls getAuthToken().

# Update your manifest with OAuth2 client ID and scopes

You need to update your manifest to include the client ID and scopes. Here's the sample "oauth2" for the gdrive sample:

"oauth2": {
"client_id": "665859454684.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/drive"
]
}

# Get access tokens

You are now ready to get the auth token by calling identity.getAuthToken.

chrome.identity.getAuthToken({ 'interactive': true }, function(token) {
// Use the token.
});

# User interaction

When calling getAuthToken, you can pass a flag ('interactive': true in the example above) indicating whether you want the API to be called in interactive mode or silent mode. If you invoke the API in interactive mode, the user is shown a sign in and/or approval UI when necessary, as shown in the screenshot below:

Chrome Apps - User Authentication [Deprecated] - Chrome Developers (1)

If you invoke the API in silent mode, the API will only return a token if it's possible to produce one without showing any UI. This is useful in cases when an app is doing the flow at app startup, for example, or in general in cases where there is no user gesture involved.

The best practice we suggest is to use silent mode when there is no user gesture involved and use interactive mode if there is a user gesture (for example, the user clicked the Sign In button in your app). Note that we do not enforce any gesture requirement.

# Caching

Chrome has an in-memory cache of access tokens, so you can call getAuthToken any time you need to use a token. Token expiration is handled automatically by the cache.

You can see the current state of the token cache on chrome://identity-internals.

There are some cases, such as when the user changes their password, when non-expired access tokens will stop working. API calls using the token will start returning with an HTTP status code 401. If you detect that this has happened, you can remove the invalid token from Chrome's cache by calling identity.removeCachedAuthToken.

Example of removeCachedAuthToken usage:

// callback = function (error, httpStatus, responseText);
function authenticatedXhr(method, url, callback) {
var retry = true;
function getTokenAndXhr() {
chrome.identity.getAuthToken({/* details */},
function (access_token) {
if (chrome.runtime.lastError) {
callback(chrome.runtime.lastError);
return;
}

var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.setRequestHeader('Authorization',
'Bearer ' + access_token);

xhr.onload = function () {
if (this.status === 401 && retry) {
// This status may indicate that the cached
// access token was invalid. Retry once with
// a fresh token.
retry = false;
chrome.identity.removeCachedAuthToken(
{ 'token': access_token },
getTokenAndXhr);
return;
}

callback(null, this.status, this.responseText);
}
});
}
}

# Non-Google account authentication

Here are the three steps you need to complete:

  1. Register with the provider.
  2. Add permissions for provider resources that your app will access.
  3. Get the authentication token.

# Register with the provider

You need to register an OAuth2 client ID with the provider and configure the client ID as a website. For the redirect URI to be entered during registration, use the URL of the form: https://<extension-id>.chromiumapp.org/<anything-here>

For example, if you app ID is abcdefghijklmnopqrstuvwxyzabcdef and you want provider_cb to be the path, to distinguish it with redirect URIs from other providers, you should use: https://abcdefghijklmnopqrstuvwxyzabcdef.chromiumapp.org/provider_cb

# Add permissions for provider

To make cross-origin XHRs to the provider API endpoints, you need to allowlist the appropriate patterns in the permissions:

"permissions": [
...
"https://www.website-of-provider-with-user-photos.com/photos/*"
]

# Get the token

To get the token:

chrome.identity.launchWebAuthFlow(
{'url': '<url-to-do-auth>', 'interactive': true},
function(redirect_url) { /* Extract token from redirect_url */ });

The <url-to-do-auth> is whatever the URL is to do auth to the provider from a website. For example, let us say that you are performing OAuth2 flow with a provider and have registered your app with client id 123456789012345 and you want access to user's photos on the provider's website: https://www.website-of-provider-with-user-photos.com/dialog/oauth?client_id=123456789012345& redirect_uri=https://abcdefghijklmnopqrstuvwxyzabcdef.chromiumapp.org/provider_cb&response_type=token&scope=user_photos

The provider will perform authentication and if appropriate, will show login and/or approval UI to the user. It will then redirect to https://abcdefghijklmnopqrstuvwxyzabcdef.chromiumapp.org/provider_cb#authToken=<auth-token>

Chrome will capture that and invoke the callback of the app with the full redirect URL. The app should extract the token out of the URL.

# Interactive versus silent mode

When calling launchWebAuthFlow, you can pass a flag ('interactive': true in the example above) indicating whether you want the API to be called in interactive mode or not (aka silent mode). If you invoke the API in interactive mode, the user is shown UI, if necessary, to get the token (signin UI and/or approval UI; or for that matter any provider specific UI).

If you invoke the API in silent mode, the API will only return a token if the provider is able to provide a token without showing any UI. This is useful in cases when an app is doing the flow at app startup, for example, or in general in cases where there is no user gesture involved.

The best practice we suggest is to use silent mode when there is no user gesture involved and use interactive mode if there is a user gesture (for example, the user clicked the Sign In button in your app). Note that we do not enforce gesture requirement.

Chrome Apps - User Authentication [Deprecated] - Chrome Developers (2024)

FAQs

Are Chrome Apps deprecated? ›

Chrome apps are deprecated and support is no longer available.

Why is Google getting rid of Chrome Apps? ›

Why are Chrome Apps going away? According to Google's Chromium blog, the decision to end support for Chrome Apps was due to two factors: the relatively low usage of Chrome Apps, and the development of technology making it easier to host applications entirely from the web.

What is the difference between PWA and Chrome app? ›

Google Chrome Apps were web applications commonly used on Chromebooks and other devices running Chrome OS. Progressive Web Apps (PWAs) are the technological successor to Chrome Apps; they are hosted entirely on the web but behave like a desktop app (opening in a separate window, for example).

Are Chrome Apps no longer available 2025? ›

Chrome Apps on Chrome OS will be supported until at least January 2025 which means Enterprise and Education customers will be allowed to use Chrome apps on Chrome OS platform until the specified month/year.

Is Chrome App no longer supported? ›

From Chrome 112, Chrome Apps on Windows, Mac, and Linux no longer work. Based on feedback from ChromeOS Enterprise and Education customers and developers, Chrome App support for those users on ChromeOS is extended until at least January 2025.

Is Google Chrome being discontinued? ›

In early 2023, Chrome will officially end support for Windows 7 and 8.1 with the release of Chrome 110, which the company “tentatively” expects to happen on February 7. This means Chrome will continue to work on these platforms but will cease receiving critical updates and new features.

What is the point of Chrome Apps? ›

Chrome Apps can integrate seamlessly into the desktop and look more like desktop applications than traditional web apps. Chrome Apps for Desktop have no omnibox (address bar) and tab strip like normal browser-based apps, because like native desktop apps, they don't live in a browser.

How do I clear Chrome authentication? ›

Clear Saved Passwords in Google Chrome

Scroll down to the "Passwords and forms" section > Click "Manage passwords." In the pop-up that appears, click the X next to any of the saved passwords that you would like to delete.

How do I turn off user authentication? ›

  1. Click the Provider Policies node to display the list of provider policies in the Results pane.
  2. Right-click the provider policy, and select Properties.
  3. Select the Provider Pipeline tab.
  4. Select the Authentication check box to enable authentication. Clear the box to disable it.
Jul 3, 2024

How do I turn off authentication app? ›

Here are the steps:
  1. Open the Microsoft Authenticator app on your device.
  2. Check the menu for “Accounts” or “Security”.
  3. Locate the account connected to the Microsoft Authenticator you wish to disable.
  4. Click on that account and remove or disable the app.

Why not to use PWA? ›

Limited discoverability: PWA is not widely available on app stores like Google Play or Apple App Store. Security risks: PWAs are vulnerable to cyberattacks and may require additional security measures to protect user data.

How do you tell if a website is a PWA? ›

You can test it by opening some pages, then turning off the network connection, and re-visiting those pages. If you still have access without the Internet, the high possibility is that it's a PWA. Finally, having a secure origin of HTTPS, not HTTP, is a must for a PWA to be worked.

Is Gmail a PWA? ›

Gmail is already a PWA, but I have seen some users who claim that it only works as a PWA in Chrome. (It does not offer the "install" option for some reason, but using the "create shortcut" menu item works.)

What is the future of Chrome Apps? ›

June 2022 is when they'll be gone for good, but it depends on which platform you're on (via 9to5Google). Previously, we knew that Chrome apps someday wouldn't work on Windows, macOS, and Linux, but today, Google revealed that Chrome apps will eventually stop working on Chrome OS, too.

What happened to my Chrome app? ›

Check to see if the icon is hidden: Go to settings> Home Screen Settings> Hide Apps on Home and apps screens. If the icon is listed in the Hidden apps category, you can unselect it and it will appear back in the App drawer.

Why are Chrome Apps not installed? ›

If you can't install an app

Make sure you have the latest version of Chrome. Learn how to update Chrome. If you're using a work or school computer, your administrator might not let you install items from the Chrome Web Store. For more help, contact your administrator.

Top Articles
Top Nigerian companies that saved funds with FTX
First Blog Income Report: How I Made $703.57 in July
Aberration Surface Entrances
Davita Internet
Asist Liberty
Craigslist Cars Augusta Ga
Limp Home Mode Maximum Derate
What Happened To Dr Ray On Dr Pol
Davante Adams Wikipedia
Free VIN Decoder Online | Decode any VIN
Aiken County government, school officials promote penny tax in North Augusta
Apnetv.con
Palace Pizza Joplin
LA Times Studios Partners With ABC News on Randall Emmett Doc Amid #Scandoval Controversy
Brenna Percy Reddit
Detroit Lions 50 50
Yesteryear Autos Slang
Craigslist Pets Longview Tx
Craigslist Deming
Craigslist Pets Athens Ohio
Viha Email Login
Patrick Bateman Notebook
Icommerce Agent
Spoilers: Impact 1000 Taping Results For 9/14/2023 - PWMania - Wrestling News
Farmer's Almanac 2 Month Free Forecast
Welcome to GradeBook
If you bought Canned or Pouched Tuna between June 1, 2011 and July 1, 2015, you may qualify to get cash from class action settlements totaling $152.2 million
Saritaprivate
SuperPay.Me Review 2023 | Legitimate and user-friendly
3569 Vineyard Ave NE, Grand Rapids, MI 49525 - MLS 24048144 - Coldwell Banker
Craigslist Comes Clean: No More 'Adult Services,' Ever
Big Boobs Indian Photos
Generator Supercenter Heartland
The Creator Showtimes Near Baxter Avenue Theatres
Florence Y'alls Standings
Missing 2023 Showtimes Near Grand Theatres - Bismarck
Housing Assistance Rental Assistance Program RAP
The Venus Flytrap: A Complete Care Guide
JD Power's top airlines in 2024, ranked - The Points Guy
Ishow Speed Dick Leak
Gateway Bible Passage Lookup
Silive Obituary
Cocorahs South Dakota
Sea Guini Dress Code
Large Pawn Shops Near Me
Muni Metro Schedule
Fine Taladorian Cheese Platter
Costner-Maloy Funeral Home Obituaries
Understanding & Applying Carroll's Pyramid of Corporate Social Responsibility
ESPN's New Standalone Streaming Service Will Be Available Through Disney+ In 2025
Invitation Quinceanera Espanol
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5849

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.