SingleAccountPublicClientApplication Class
- java.
lang. Object - IPublicClientApplication
- PublicClientApplication
- com.
microsoft. identity. client. SingleAccountPublicClientApplication
- com.
public class SingleAccountPublicClientApplication extends PublicClientApplication implements ISingleAccountPublicClientApplication
Field Summary
Modifier and Type | Field and Description |
---|---|
final String |
CURRENT_ACCOUNT_SHARED_PREFERENCE_KEY
SharedPreference key for storing current account. |
final String |
SINGLE_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES
Name of the shared preference cache for storing SingleAccountPublicClientApplication data. |
Constructor Summary
Constructor | Description | |
---|---|---|
SingleAccountPublicClientApplication(@NonNull final PublicClientApplicationConfiguration config) |
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. |
IAuthentication |
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. |
IAuthentication |
acquireTokenSilent(@NonNull final String[] scopes, @NonNull final String authority)
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 |
acquireTokenSilentAsync(@NonNull final String[] scopes, @NonNull final String authority, @NonNull final SilentAuthenticationCallback callback)
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. |
CommandCallback<ILocalAuthenticationResult, BaseException> | getCommandCallback( @NonNull final SilentAuthenticationCallback authenticationCallback, @NonNull final TokenParameters tokenParameters) |
ICurrent |
getCurrentAccount()
Gets the current account and notify if the current account changes. This method must be called whenever the application is resumed or prior to running a scheduled background operation. |
void | getCurrentAccountAsync(@NonNull final CurrentAccountCallback callback) |
void |
signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts. This method may only be called once: once a user is signed in, they must first be signed out before another user may sign in. If you wish to prompt the existing user for credentials use signInAgain(Activity, String[], Prompt, AuthenticationCallback) or acquireToken(AcquireTokenParameters). Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration |
void |
signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts. This method may only be called once: once a user is signed in, they must first be signed out before another user may sign in. If you wish to prompt the existing user for credentials use signInAgain(Activity, String[], Prompt, AuthenticationCallback) or acquireToken(AcquireTokenParameters). Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration |
void |
signInAgain(@NonNull final Activity activity, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)
Reauthorizes the current account according to the supplied scopes and prompt behavior. Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration. |
boolean |
signOut()
Signs out the current the Account and Credentials (tokens). NOTE: If a device is marked as a shared device within broker signout will be device wide. |
void |
signOut(@NonNull final SignOutCallback callback)
Signs out the current the Account and Credentials (tokens). NOTE: If a device is marked as a shared device within broker signout will be device wide. |
Inherited Members
Field Details
CURRENT_ACCOUNT_SHARED_PREFERENCE_KEY
public static final String CURRENT_ACCOUNT_SHARED_PREFERENCE_KEY= "com.microsoft.identity.client.single_account_credential_cache.current_account"
SharedPreference key for storing current account.
SINGLE_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES
public static final String SINGLE_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES= "com.microsoft.identity.client.single_account_credential_cache"
Name of the shared preference cache for storing SingleAccountPublicClientApplication data.
Constructor Details
SingleAccountPublicClientApplication
protected SingleAccountPublicClientApplication(@NonNull final PublicClientApplicationConfiguration config)
Parameters:
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
Overrides:
SingleAccountPublicClientApplication.acquireToken(@NonNull final AcquireTokenParameters acquireTokenParameters)Parameters:
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.
Overrides:
SingleAccountPublicClientApplication.acquireToken(@NonNull final Activity activity, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)Parameters:
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.
Overrides:
SingleAccountPublicClientApplication.acquireTokenSilent(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)Parameters:
acquireTokenSilent
public IAuthenticationResult acquireTokenSilent(@NonNull final String[] scopes, @NonNull final String authority)
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.
Overrides:
SingleAccountPublicClientApplication.acquireTokenSilent(@NonNull final String[] scopes, @NonNull final String authority)Parameters:
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.
Overrides:
SingleAccountPublicClientApplication.acquireTokenSilentAsync(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)Parameters:
acquireTokenSilentAsync
public void acquireTokenSilentAsync(@NonNull final String[] scopes, @NonNull final String authority, @NonNull final SilentAuthenticationCallback callback)
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.
Overrides:
SingleAccountPublicClientApplication.acquireTokenSilentAsync(@NonNull final String[] scopes, @NonNull final String authority, @NonNull final SilentAuthenticationCallback callback)Parameters:
SilentAuthenticationCallback that is used to send the result back. The success result will be sent back via onSuccess(final IAuthenticationResult authenticationResult). Failure case will be sent back via { onError(final MsalException exception)
getCommandCallback
protected CommandCallback
Parameters:
getCurrentAccount
public ICurrentAccountResult getCurrentAccount()
Gets the current account and notify if the current account changes. This method must be called whenever the application is resumed or prior to running a scheduled background operation.
Overrides:
SingleAccountPublicClientApplication.getCurrentAccount()Returns:
getCurrentAccountAsync
public void getCurrentAccountAsync(@NonNull final CurrentAccountCallback callback)
Parameters:
signIn
public void signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts. This method may only be called once: once a user is signed in, they must first be signed out before another user may sign in. If you wish to prompt the existing user for credentials use signInAgain(Activity, String[], Prompt, AuthenticationCallback) or acquireToken(AcquireTokenParameters).
Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration
Overrides:
SingleAccountPublicClientApplication.signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @NonNull final AuthenticationCallback callback)Parameters:
AuthenticationCallback that is used to send the result back. The success result will be sent back via onSuccess(final IAuthenticationResult authenticationResult). Failure case will be sent back via { onError(final MsalException exception)
signIn
public void signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts. This method may only be called once: once a user is signed in, they must first be signed out before another user may sign in. If you wish to prompt the existing user for credentials use signInAgain(Activity, String[], Prompt, AuthenticationCallback) or acquireToken(AcquireTokenParameters).
Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration
Overrides:
SingleAccountPublicClientApplication.signIn(@NonNull final Activity activity, @Nullable final String loginHint, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)Parameters:
AuthenticationCallback that is used to send the result back. The success result will be sent back via onSuccess(final IAuthenticationResult authenticationResult). Failure case will be sent back via { onError(final MsalException exception)
signInAgain
public void signInAgain(@NonNull final Activity activity, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)
Reauthorizes the current account according to the supplied scopes and prompt behavior.
Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common or the default authority specified by you in your configuration.
Overrides:
SingleAccountPublicClientApplication.signInAgain(@NonNull final Activity activity, @NonNull final String[] scopes, @Nullable final Prompt prompt, @NonNull final AuthenticationCallback callback)Parameters:
AuthenticationCallback that is used to send the result back. The success result will be sent back via onSuccess(final IAuthenticationResult authenticationResult). Failure case will be sent back via onError(final MsalException exception).
signOut
public boolean signOut()
Signs out the current the Account and Credentials (tokens). NOTE: If a device is marked as a shared device within broker signout will be device wide.
Overrides:
SingleAccountPublicClientApplication.signOut()Returns:
signOut
public void signOut(@NonNull final SignOutCallback callback)
Signs out the current the Account and Credentials (tokens). NOTE: If a device is marked as a shared device within broker signout will be device wide.
Overrides:
SingleAccountPublicClientApplication.signOut(@NonNull final SignOutCallback callback)Parameters:
Applies to
Azure SDK for Java