Credential management
The Credential interface of the Credential Management API provides information about an entity (usually a user) normally as a prerequisite to a trust decision.
Credential objects may be of the following types:
FederatedCredential
IdentityCredential
PasswordCredential
PublicKeyCredential
OTPCredential
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 51 | 18 | 60 | 13 | 51 | 13 | |
| The id read-only property of the Credential interface returns a string containing the credential's identifier. This might be a GUID, username, or email address, or some other value, depending on the type of credential. | 51 | 18 | 60 | 13 | 51 | 13 |
isConditionalMediationAvailable_static Experimental The isConditionalMediationAvailable() static method of the Credential interface returns a Promise which resolves to false. | | | | 16 | | 16 |
| The type read-only property of the Credential interface returns a string containing the credential's type. Valid values are password, federated, public-key, identity and otp. | 51 | 18 | 60 | 13 | 51 | 13 |
| The CredentialsContainer interface of the Credential Management API exposes methods to request credentials and notify the user agent when events such as successful sign in or sign out happen. This interface is accessible from Navigator.credentials. | 51 | 18 | 60 | 13 | 51 | 13 |
| The create() method of the CredentialsContainer interface creates a new credential, which can then be stored and later retrieved using the CredentialsContainer.get method. The retrieved credential can then be used by a website to authenticate a user. | 60 | 18 | 60 | 13 | 60 | 13 |
| The get() method of the CredentialsContainer interface returns a Promise that fulfills with a single credential, which can then be used to authenticate a user to a website. | 51 | 18 | 60 | 13 | 51 | 13 |
| The preventSilentAccess() method of the CredentialsContainer interface sets a flag that specifies whether automatic log in is allowed for future visits to the current origin, then returns a Promise that resolves to undefined. For example, you might call this, after a user signs out of a website to ensure that they aren't automatically signed in on the next… | 60 | 18 | 60 | 17 | 60 | 17 |
| The store() method of the CredentialsContainer stores a set of credentials for the user inside a Credential instance, returning this in a Promise. | 51 | 79 | 60 | 13 | 51 | 13 |
| The credentials read-only property of the Navigator interface returns the CredentialsContainer object associated with the current document, which exposes methods to request credentials. The CredentialsContainer interface also notifies the user agent when an interesting event occurs, such as a successful sign-in or sign-out. This interface can be used for… | 51 | 18 | 60 | 13 | 51 | 13 |
- This feature was removed in a later browser version (60)
- Previously available under a different name: requireUserMediation (51)
- This browser only partially implements this feature
- This feature was removed in a later browser version (17)
- This method exists, but always rejected with a `NotSupportedError` exception.
- This feature was removed in a later browser version (60)
- Previously available under a different name: requireUserMediation (51)
- This browser only partially implements this feature
- This feature was removed in a later browser version (17)
- This method exists, but always rejected with a `NotSupportedError` exception.
Syntax
const pwdCredential = new PasswordCredential({
id: "example-username", // Username/ID
name: "Carina Anand", // Display name
password: "correct horse battery staple", // Password
});
console.assert(pwdCredential.type === "password"); Use cases
-
Using Credential management
The Credential interface of the Credential Management API provides information about an entity (usually a user) normally as a prerequisite to a trust decision.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.