大网数据广告活动
Web 标准与前端开发

FederatedCredentialInit

· 52CE 我爱测

The **`FederatedCredentialInit`** dictionary represents the object passed to CredentialsContainer.create() as the value of the `federated` option: that is, when creating a FederatedCredential object representing a credential associated with a federated identify provider.

Credential Management API

The FederatedCredentialInit dictionary represents the object passed to CredentialsContainer.create() as the value of the federated option: that is, when creating a FederatedCredential object representing a credential associated with a federated identify provider.

[!NOTE] The Federated Credential Management API (FedCM) supersedes the FederatedCredential interface in favor of the IdentityCredential interface.

The FederatedCredentialInit dictionary is not used when working with the IdentityCredential interface.

Instance properties

  • iconURL
    • : A string representing the URL of an icon or avatar to be associated with the credential.
  • id
    • : A string representing a unique ID for the credential.
  • name
    • : A string representing the credential username.
  • origin
    • : A string representing the credential's origin. FederatedCredential objects are origin-bound, which means that they will only be usable on the specified origin they were intended to be used on.
  • protocol
    • : A string representing the protocol of the credentials' federated identity provider (for example, "openidconnect").
  • provider
    • : A string representing the credentials' federated identity provider (for example "https://www.facebook.com" or "https://accounts.google.com").

Examples

Creating a federated identity credential

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

const makeCredential = document.querySelector("#make-credential");

makeCredential.addEventListener("click", async () => {
  const cred = await navigator.credentials.create({
    federated: credInit,
  });
  console.log(cred.name);
  console.log(cred.provider);
});

Specifications

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。