Partager via


PublicClientApplication Class

Implements

public class PublicClientApplication
extends AbstractClientApplicationBase
implements IPublicClientApplication

Class to be used to acquire tokens for public client applications (Desktop, Mobile). For details see IPublicClientApplication

Conditionally thread-safe

Method Summary

Modifier and Type Method and Description
java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(DeviceCodeFlowParameters parameters)

Acquires security token from the authority using an device code flow.

java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(IntegratedWindowsAuthenticationParameters parameters)

Acquires tokens from the authority configured in the application via Integrated Windows Authentication.

java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(InteractiveRequestParameters parameters)

Acquires tokens from the authority using authorization code grant.

java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(UserNamePasswordParameters parameters)

Acquires tokens from the authority configured in the application via Username/Password authentication.

java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireTokenSilently(SilentParameters parameters)

Returns tokens from cache if present and not expired or acquires new tokens from the authority by using the refresh token present in cache.

static Builder builder(String clientId)
protected com.nimbusds.oauth2.sdk.auth.ClientAuthentication clientAuthentication()
java.util.concurrent.CompletableFuture<java.lang.Void> removeAccount(IAccount account)

Removes IAccount from the cache

Methods inherited from AbstractApplicationBase

Methods inherited from AbstractClientApplicationBase

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

acquireToken

public CompletableFuture acquireToken(DeviceCodeFlowParameters parameters)

Acquires security token from the authority using an device code flow. Flow is designed for devices that do not have access to a browser or have input constraints. The authorization server issues DeviceCode object with verification code, an end-user code and the end-user verification URI. DeviceCode is provided through deviceCodeConsumer callback. End-user should be instructed to use another device to connect to the authorization server to approve the access request. Since the client cannot receive incoming requests, it polls the authorization server repeatedly until the end-user completes the approval process.

Parameters:

parameters

acquireToken

public CompletableFuture acquireToken(IntegratedWindowsAuthenticationParameters parameters)

Acquires tokens from the authority configured in the application via Integrated Windows Authentication.

Parameters:

parameters

acquireToken

public CompletableFuture acquireToken(InteractiveRequestParameters parameters)

Acquires tokens from the authority using authorization code grant. Will attempt to open the default system browser where the user can input the credentials interactively, consent to scopes, and do multi-factor authentication if such a policy is enabled on the Azure AD tenant. System browser can behavior can be customized via InteractiveRequestParameters#systemBrowserOptions. For more information, see https://aka.ms/msal4j-interactive-request

Parameters:

parameters

acquireToken

public CompletableFuture acquireToken(UserNamePasswordParameters parameters)

Acquires tokens from the authority configured in the application via Username/Password authentication.

Parameters:

parameters

acquireTokenSilently

public CompletableFuture acquireTokenSilently(SilentParameters parameters)

Returns tokens from cache if present and not expired or acquires new tokens from the authority by using the refresh token present in cache.

Overrides:

PublicClientApplication.acquireTokenSilently(SilentParameters parameters)

Parameters:

parameters

Throws:

java.net.MalformedURLException

builder

public static PublicClientApplication.Builder builder(String clientId)

Parameters:

clientId - Client ID (Application ID) of the application as registered in the application registration portal (portal.azure.com)

Returns:

instance of Builder of PublicClientApplication

clientAuthentication

protected ClientAuthentication clientAuthentication()

Overrides:

PublicClientApplication.clientAuthentication()

removeAccount

public CompletableFuture removeAccount(IAccount account)

Removes IAccount from the cache

Overrides:

PublicClientApplication.removeAccount(IAccount account)

Parameters:

account

Applies to