Table of Contents

Class CredentialsContainer

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

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'.

[Value("CredentialsContainer")]
public class CredentialsContainer
Inheritance
CredentialsContainer
Inherited Members

Remarks

Constructors

CredentialsContainer()

public CredentialsContainer()

Methods

Create(CredentialCreationOptions)

The create() method of the CredentialsContainer interface creates a new {{glossary("credential")}}, which can then be stored and later retrieved using the Get(CredentialRequestOptions) method. The retrieved credential can then be used by a website to authenticate a user.

[Value("create")]
public Task<Credential?> Create(CredentialCreationOptions options = null)

Parameters

options CredentialCreationOptions

Returns

Task<Credential>

A Promise that resolves with one of the following:If no credential object can be created, the promise resolves with null.

Remarks

This method supports three different types of credential:

Note that the Federated Credential Management API (FedCM) supersedes the federated credential type.

See also on MDN

Get(CredentialRequestOptions)

The get() method of the CredentialsContainer interface returns a {{jsxref("Promise")}} that fulfills with a single {{glossary("credential")}}, which can then be used to authenticate a user to a website.

[Value("get")]
public Task<Credential?> Get(CredentialRequestOptions options = null)

Parameters

options CredentialRequestOptions

Returns

Task<Credential>

A {{jsxref("Promise")}} that resolves with one of the following subclasses of Credential:If conditional mediation was specified in the get() call, the browser UI dialog is shown and the promise remains pending until the user picks an account to sign-in with from available autofill suggestions:If a single credential cannot be unambiguously obtained, the promise resolves with null.

Remarks

The method accepts a single optional options argument, which may include:

The API always fulfills with a single credential or null. If multiple credentials are available and user mediation is allowed, then the browser will ask the user to select a single credential.

See also on MDN

PreventSilentAccess()

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 {{jsxref("Promise")}} that resolves to undefined.
For example, you might call this, after a user signs out of a website to ensure that they aren&apos;t automatically signed in on the next site visit.
Mediation varies by origin, and is an added check point of browser stored credentials, informing a user of an account login status. This method is typically called after a user signs out of a website, ensuring this user&apos;s login information is not automatically passed on the next site visit.

[Value("preventSilentAccess")]
public Task<GlobalObject.Undefined> PreventSilentAccess()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves to undefined.

Remarks

When using a PublicKeyCredential, this method generally has no effect; such authenticators typically require user interaction. However, it is possible that certain authenticators may be excluded, which could otherwise have operated silently.

Earlier versions of the spec called this method requireUserMediation().
The Browser compatibility section has support details.

See also on MDN

Store(Credential)

The store() method of the
CredentialsContainer stores a set of credentials for the user inside a
Credential instance, returning this in a {{jsxref("Promise")}}.

[Value("store")]
public Task<GlobalObject.Undefined> Store(Credential credential)

Parameters

credential Credential

Returns

Task<GlobalObject.Undefined>

A Promise that resolves to undefined.

Remarks

NOTE

This method is restricted to top-level contexts. Calls to it within an
&lt;iframe&gt; element will resolve without effect.

See also on MDN