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

IdentityCredential: disconnect() static method

· 52CE 我爱测

The **`disconnect()`** static method of the IdentityCredential interface disconnects a specified federated sign-in account from the Identity provider used to obtain the credential.

FedCM API

The disconnect() static method of the IdentityCredential interface disconnects a specified federated sign-in account from the Identity provider used to obtain the credential.

Afterwards, using that account for federated login requires starting the federated sign-in process again.

Syntax

IdentityCredential.disconnect(options)

Parameters

  • options
    • : An options object, which can contain the following properties:
      • accountHint
        • : A string specifying an account hint that the IdP uses to identify the account to disconnect. The hint can be an arbitrary string as long as the disconnect endpoint can identify the account — for example an email address or user ID. This will not necessarily match the account ID provided by the accounts list endpoint.
      • clientId
        • : A string specifying the Relying party's client identifier, as specified in the providers clientId property during sign-in.
      • configURL
        • : A string specifying the config file URL of the IdP, as specified in the providers configURL property during sign-in.

Return value

A Promise that fulfills with undefined.

Exceptions

  • InvalidStateError DOMException
    • : Thrown if:
      • The IdP's configURL is invalid or missing the disconnect_endpoint.
      • The document's origin does not match the configURL.
  • NetworkError DOMException
    • : Thrown if:
      • The browser is unable to connect to the IdP.
      • The request is disallowed by a connect-src Content-Security-Policy.
      • Another disconnect() call was previously made that has not yet resolved.
      • The FedCM API has been disabled globally.
      • The IdP's configURL is neither secure nor potentially trustworthy.
  • NotAllowedError DOMException
    • : Thrown if the embedding <iframe> does not have an Permissions-Policy/identity-credentials-get Permissions-Policy set to allow the use of disconnect() or if the FedCM API is disabled globally by a policy set on the top-level document.

Examples

Basic disconnect() usage

The RP may disconnect a specified federated sign-in account from the associated IdP by invoking disconnect(). This function can be called from a top-level RP frame.

IdentityCredential.disconnect({
  configURL: "https://idp.example.com/config.json",
  clientId: "rp123",
  accountHint: "account456",
});

For a disconnect() call to work, the IdP must include a disconnect_endpoint in its config file. See The disconnect endpoint for more details of the underlying HTTP communication.

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

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

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