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
new FederatedCredential(data)
Parameters
data-
A
FederatedCredentialInitobject. An object with the following properties:nameOptional-
A string representing the credential username.
iconURLOptional-
A string representing the URL of an icon or avatar to be associated with the credential.
origin-
A string representing the credential's origin.
FederatedCredentialobjects 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"). protocolOptional-
A string representing the protocol of the credentials' federated identity provider (for example,
"openidconnect").
Examples
>Creating a federated identity credential
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> |