IPublicClientApplication Interface

public interface IPublicClientApplication

Method Summary

Modifier and Type Method and Description
void acquireToken(@NonNull final AcquireTokenParameters acquireTokenParameters)

Acquire token interactively, will pop-up webUI. Interactive flow will skip the cache lookup. Default value for Prompt is SELECT_ACCOUNT.

Convey parameters via the AquireTokenParameters object

void acquireToken(@NonNull final Activity activity, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)

Acquire token interactively, will pop-up webUI. Interactive flow will skip the cache lookup. Default value for Prompt is SELECT_ACCOUNT.

IAuthenticationResult acquireTokenSilent(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)

Perform acquire token silent call. If there is a valid access token in the cache, the sdk will return the access token; If no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist or it fails the refresh, exception will be sent back via callback.

void acquireTokenSilentAsync(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)

Perform acquire token silent call. If there is a valid access token in the cache, the sdk will return the access token; If no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist or it fails the refresh, exception will be sent back via callback.

void acquireTokenWithDeviceCode(@NonNull String[] scopes, @NonNull final DeviceCodeFlowCallback callback)

Perform the Device Code Flow (DCF) protocol to allow a device without input capability to authenticate and get a new access token. Currently, flow is only supported in local MSAL. No Broker support.

String generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters)

Signs the provided PoPAuthenticationScheme parameters into a JWT on behalf of the provided IAccount.

Important: Use of this API requires setting the minimum_required_broker_protocol_version to "6.0" or higher.

void generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters, @NonNull final SignedHttpRequestRequestCallback callback)

Signs the provided PoPAuthenticationScheme parameters into a JWT on behalf of the provided IAccount.

Important: Use of this API requires setting the minimum_required_broker_protocol_version to "6.0" or higher.

PublicClientApplicationConfiguration getConfiguration()

Returns the PublicClientConfiguration for this instance of PublicClientApplication.

boolean isSharedDevice()

Returns whether the application is being run on a device that is marked as a shared. Only SingleAccountPublicClientApplications may be used on shared devices

Method Details

acquireToken

public void acquireToken(@NonNull final AcquireTokenParameters acquireTokenParameters)

Acquire token interactively, will pop-up webUI. Interactive flow will skip the cache lookup. Default value for Prompt is SELECT_ACCOUNT.

Convey parameters via the AquireTokenParameters object

Parameters:

acquireTokenParameters

acquireToken

public void acquireToken(@NonNull final Activity activity, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)

Acquire token interactively, will pop-up webUI. Interactive flow will skip the cache lookup. Default value for Prompt is SELECT_ACCOUNT.

Parameters:

activity - Non-null Activity that is used as the parent activity for launching the com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity.
scopes - The non-null array of scopes to be requested for the access token. MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
callback - The AuthenticationCallback to receive the result back. 1) If user cancels the flow by pressing the device back button, the result will be sent back via onCancel(). 2) If the sdk successfully receives the token back, result will be sent back via onSuccess(final IAuthenticationResult authenticationResult) 3) All the other errors will be sent back via onError(final MsalException exception).

acquireTokenSilent

public IAuthenticationResult acquireTokenSilent(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)

Perform acquire token silent call. If there is a valid access token in the cache, the sdk will return the access token; If no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist or it fails the refresh, exception will be sent back via callback.

Parameters:

acquireTokenSilentParameters

acquireTokenSilentAsync

public void acquireTokenSilentAsync(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)

Perform acquire token silent call. If there is a valid access token in the cache, the sdk will return the access token; If no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist or it fails the refresh, exception will be sent back via callback.

Parameters:

acquireTokenSilentParameters

acquireTokenWithDeviceCode

public void acquireTokenWithDeviceCode(@NonNull String[] scopes, @NonNull final DeviceCodeFlowCallback callback)

Perform the Device Code Flow (DCF) protocol to allow a device without input capability to authenticate and get a new access token. Currently, flow is only supported in local MSAL. No Broker support.

Parameters:

scopes - the desired access scopes
callback - callback object used to communicate with the API throughout the protocol

generateSignedHttpRequest

public String generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters)

Signs the provided PoPAuthenticationScheme parameters into a JWT on behalf of the provided IAccount.

Important: Use of this API requires setting the minimum_required_broker_protocol_version to "6.0" or higher.

Parameters:

account - The account for whom signing shall occur.
popParameters - The input parameters.

Returns:

The resulting SHR.

generateSignedHttpRequest

public void generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters, @NonNull final SignedHttpRequestRequestCallback callback)

Signs the provided PoPAuthenticationScheme parameters into a JWT on behalf of the provided IAccount.

Important: Use of this API requires setting the minimum_required_broker_protocol_version to "6.0" or higher.

Parameters:

account - The account for whom signing shall occur.
popParameters - The input parameters.
callback - The callback object to receive the result (or error).

getConfiguration

public PublicClientApplicationConfiguration getConfiguration()

Returns the PublicClientConfiguration for this instance of PublicClientApplication.

Returns:

The PublicClientApplicationConfiguration.

isSharedDevice

public boolean isSharedDevice()

Returns whether the application is being run on a device that is marked as a shared. Only SingleAccountPublicClientApplications may be used on shared devices

Applies to