Condividi tramite


IPublicClientApplication Interface

Definition

Represents public client applications - desktop and mobile applications.

public interface IPublicClientApplication : Microsoft.Identity.Client.IClientApplicationBase
type IPublicClientApplication = interface
    interface IClientApplicationBase
    interface IApplicationBase
Public Interface IPublicClientApplication
Implements IClientApplicationBase
Derived
Implements

Remarks

Public client applications are not trusted to safely keep application secrets and therefore they can only access web APIs in the name of the authenticating user. See Client Applications.

Unlike IConfidentialClientApplication, public clients are unable to securely store secrets on a client device and as a result do not require the use of a client secret.

The redirect URI needed for interactive authentication is automatically determined by the library. It does not need to be passed explicitly in the constructor. Depending on the authentication strategy (e.g., through the Web Account Manager, the Authenticator app, web browser, etc.), different redirect URIs will be used by MSAL. Redirect URIs must always be configured for the application in the Azure Portal.

Properties

AppConfig

Details on the configuration of the ClientApplication for debugging purposes.

(Inherited from IClientApplicationBase)
Authority

Gets the URL of the authority, or the security token service (STS) from which MSAL.NET will acquire security tokens. The return value of this property is either the value provided by the developer in the constructor of the application, or otherwise the value of the Microsoft.Identity.Client.ApplicationBase.DefaultAuthority static member (that is https://login.microsoftonline.com/common/)

(Inherited from IClientApplicationBase)
IsSystemWebViewAvailable

Tells if the application can use the system web browser, therefore enabling single-sign-on with web applications. By default, MSAL will try to use a system browser on the mobile platforms, if it is available. See our documentation for more details.

UserTokenCache

User token cache which holds ID tokens, access tokens, and refresh tokens for accounts. It's used and updated silently if needed when calling AcquireTokenSilent(IEnumerable<String>, IAccount) It is updated by each acquire token method, with the exception of AcquireTokenForClient(IEnumerable<String>) which only uses the application cache (see AppTokenCache).

(Inherited from IClientApplicationBase)

Methods

AcquireTokenByIntegratedWindowsAuth(IEnumerable<String>)

This API is no longer recommended and will be deprecated in future versions in favor of similar functionality via the Windows broker (WAM). WAM does not require any setup for desktop apps to login with the Windows account.

Acquires a token non-interactively for the signed-in user in Windows via Integrated Windows Authentication. The account used in this overrides is pulled from the operating system as the current user principal name. This method does not look in the token cache, but stores the result in it. Before calling this method, use other methods such as AcquireTokenSilent(IEnumerable<String>, IAccount) to check the token cache.

AcquireTokenByUsernamePassword(IEnumerable<String>, String, SecureString)
Obsolete.

Non-interactive request to acquire a token via username and password authentication.

AcquireTokenByUsernamePassword(IEnumerable<String>, String, String)

Acquires a token without user interaction using username and password authentication. This method does not look in the token cache, but stores the result in it. Before calling this method, use other methods such as AcquireTokenSilent(IEnumerable<String>, IAccount) to check the token cache.

AcquireTokenInteractive(IEnumerable<String>)

Acquires a token interactively for the specified scopes. Either a system browser, an embedded browser, or a broker will handle this request, depending on the version of .NET framework used and on configuration. For Microsoft Entra applications, a broker is recommended. See Windows Broker. This method does not look in the token cache, but stores the result in it. Before calling this method, use other methods such as AcquireTokenSilent(IEnumerable<String>, IAccount) to check the token cache. See Interactive Authentication.

AcquireTokenSilent(IEnumerable<String>, IAccount)

Attempts to acquire an access token for the account from the user token cache, with advanced parameters controlling the network call. See Acquire tokens silently.

(Inherited from IClientApplicationBase)
AcquireTokenSilent(IEnumerable<String>, String)

Attempts to acquire an access token for the loginHint from the user token cache, with advanced parameters controlling the network call. See Acquire tokens silently.

(Inherited from IClientApplicationBase)
AcquireTokenWithDeviceCode(IEnumerable<String>, Func<DeviceCodeResult,Task>)

Acquires a token on a device without a web browser by letting the user authenticate on another device. This method does not look in the token cache, but stores the result in it. Before calling this method, use other methods such as AcquireTokenSilent(IEnumerable<String>, IAccount) to check the token cache.

GetAccountAsync(String)

Get the IAccount by its identifier among the accounts available in the token cache and of the same environment (authority host) as Authority.

(Inherited from IClientApplicationBase)
GetAccountsAsync()

Returns all the available accounts in the user token cache for the application.

(Inherited from IClientApplicationBase)
GetAccountsAsync(String)

Only for Azure AD B2C scenarios, get the IAccount collection by its identifier among the accounts available in the token cache based on the user flow.

(Inherited from IClientApplicationBase)
RemoveAsync(IAccount)

Removes all tokens in the cache for the specified account.

(Inherited from IClientApplicationBase)

Extension Methods

IsEmbeddedWebViewAvailable(IPublicClientApplication)

Returns true if MSAL can use an embedded webview (browser).

IsSystemWebViewAvailable(IPublicClientApplication)

Returns true if MSAL can use a system browser.

IsUserInteractive(IPublicClientApplication)

Returns false when the program runs in headless OS, for example when SSH-ed into a Linux machine. Browsers (webviews) and brokers cannot be used if there is no UI support. Instead, please use AcquireTokenWithDeviceCode(IEnumerable<String>, Func<DeviceCodeResult,Task>) or AcquireTokenByIntegratedWindowsAuth(IEnumerable<String>)

IsProofOfPossessionSupportedByClient(IPublicClientApplication)

Used to determine if the currently available broker is able to perform Proof-of-Possession.

Applies to