Credential Management API
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 Window/fetch.
Syntax
new FederatedCredential(data)
Parameters
data- : A FederatedCredentialInit object. An object with the following properties:
name- : A string representing the credential username.
iconURL- : 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").
- : A string which identifies the credentials' federated identity provider, specified as the origin that the provider uses to sign users in (for example
protocol- : A string representing the protocol of the credentials' federated identity provider (for example,
"openidconnect").
- : A string representing the protocol of the credentials' federated identity provider (for example,
- : A FederatedCredentialInit object. An object with the following properties:
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
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
