IdentityCredential
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
TheIdentityCredential interface of theFederated Credential Management API (FedCM) represents a user identity credential arising from a successful federated sign-in.
A successfulnavigator.credentials.get() call that includes anidentity option fulfills with anIdentityCredential instance.
In this article
Instance properties
Inherits properties from its ancestor,Credential.
IdentityCredential.configURLRead onlyExperimentalA string specifying theconfig file URL of theIdP used for sign-in.
IdentityCredential.isAutoSelectedRead onlyExperimentalA boolean value that indicates whether the federated sign-in was carried out usingauto-reauthentication (i.e., without user mediation) or not.
IdentityCredential.tokenExperimentalReturns the token used to validate the associated sign-in.
Static methods
IdentityCredential.disconnect()ExperimentalDisconnects the federated sign-in account used to obtain the credential.
Examples
>Basic federated sign-in
Relying parties (RPs) can callnavigator.credentials.get() with theidentity option to make a request for users to sign in to the RP via an identity provider (IdP), using identity federation. A typical request would look like this:
async function signIn() { const identityCredential = await navigator.credentials.get({ identity: { providers: [ { configURL: "https://accounts.idp.example/config.json", clientId: "********", nonce: "******", }, ], }, });}If successful, this call will fulfill with anIdentityCredential instance. From this, you could return theIdentityCredential.token value, for example:
console.log(identityCredential.token);Check outFederated Credential Management API (FedCM) for more details on how this works. This call will start off the sign-in flow described inFedCM sign-in flow.
Specifications
| Specification |
|---|
| Federated Credential Management API> # browser-api-identity-credential-interface> |