静态方法
close()实验性-
向浏览器发出信号,表示 IdP 登录流程已完成。这对于例如在登录完全完成后且 IdP 已完成从用户收集数据时关闭 IdP 登录对话框是必需的。
getUserInfo()实验性-
在用户返回 IdP 时,返回有关先前已登录用户的信息,可用于提供个性化的欢迎消息和登录按钮。
示例
IdentityProvider.getUserInfo() 的基本用法
以下示例展示了如何使用 getUserInfo() 方法返回特定 IdP 中先前已登录用户的信息。
js
// 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
}
规范
| 规范 |
|---|
| Federated Credential Management API # browser-api-identity-provider-interface |
浏览器兼容性
加载中…
另见
- Federated Credential Management API on privacysandbox.google.com (2023)