FederatedCredential: FederatedCredential() constructor

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The FederatedCredential() constructor creates a new FederatedCredential object. In supporting browsers, an instance of this class may be passed the credential received from the init object for global fetch().

Syntax

js
new FederatedCredential(data)

Parameters

data

A FederatedCredentialInit object. An object with the following properties:

name Optional

A string representing the credential username.

iconURL Optional

A string representing the URL of an icon or avatar to be associated with the credential.

origin

A string representing the credential's origin. FederatedCredential objects are origin-bound, so they will only be usable on the origin specified here.

provider

A string which identifies the credentials' federated identity provider, specified as the origin that the provider uses to sign users in (for example "https://www.facebook.com" or "https://accounts.google.com").

protocol Optional

A string representing the protocol of the credentials' federated identity provider (for example, "openidconnect").

Examples

Creating a federated identity credential

js
const credData = {
  id: "1234",
  name: "Serpentina",
  origin: "https://example.org",
  protocol: "openidconnect",
  provider: "https://provider.example.org",
};

const fedCred = new FederatedCredential(credData);

// Store it
navigator.credentials.store(fedCred).then(() => {
  // Do something else
});

Specifications

Specification
Credential Management Level 1
# dom-federatedcredential-federatedcredential

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
FederatedCredential() constructor
Experimental
Chrome – Full support
Chrome 51 (Release date: 2016-05-25)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 38 (Release date: 2016-06-08)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 51 (Release date: 2016-06-08)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 51 (Release date: 2016-06-08)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.