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

IdentityProvider

· 52CE 我爱测

The **`IdentityProvider`** interface of the Federated Credential Management (FedCM) API represents an Identity provider and provides access to related information and functionality.

FedCM API

The IdentityProvider interface of the Federated Credential Management (FedCM) API represents an Identity provider and provides access to related information and functionality.

Static methods

  • IdentityProvider.close_static
    • : Provides a manual signal to the browser that an IdP sign-in flow is finished. This is needed to, for example, close the IdP sign-in dialog when sign-in is completely finished and the IdP has finished collecting data from the user.
  • IdentityProvider.getUserInfo_static
    • : Returns information about a previously-signed in user on their return to an IdP, which can be used to provide a personalized welcome message and sign-in button.

Examples

Basic IdentityProvider.getUserInfo() usage

The following example shows how the IdentityProvider.getUserInfo_static method can be used to return information on a previously-signed in user from a specific IdP.

// Iframe displaying a page from the https://idp.example origin
const userInfo = await IdentityProvider.getUserInfo({
  configURL: "https://idp.example/fedcm.json",
  clientId: "client1234",
});

// IdentityProvider.getUserInfo() returns an array of user information.
if (userInfo.length > 0) {
  // Returning accounts should be first, so the first account received
  // is guaranteed to be a returning account
  const name = userInfo[0].name;
  const givenName = userInfo[0].given_name;
  const displayName = givenName || name;
  const picture = userInfo[0].picture;
  const email = userInfo[0].email;

  // …

  // Render a personalized sign-in button using the information returned above
}

Specifications

Browser compatibility

See also

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

资料来源与适用范围

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

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

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