files/en-us/web/api/identityprovider/index.md
{{APIRef("FedCM API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The IdentityProvider interface of the Federated Credential Management (FedCM) API represents an {{glossary("Identity provider", "IdP")}} and provides access to related information and functionality.
{{InheritanceDiagram}}
IdentityProvider.getUserInfo() usageThe following example shows how the {{domxref("IdentityProvider.getUserInfo_static", "getUserInfo()")}} 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}}
{{Compat}}