ISingleAccountPublicClientApplication Interface
public interface ISingleAccountPublicClientApplication extends IPublicClientApplication
An interface that contains list of operations that are available when MSAL is in 'single account' mode.
In this mode, one account can be signed-in to the app.
If the user wants to acquire a token for another account, the previous account must be signed out first.
When the device is registered as 'shared', this will be the only available PublicClientApplication the app can obtain. The calling app has to support ISingleAccountPublicClientApplication if it is planning to support shared device mode.
In the shared device mode,
'Sign-in' means that the user will be signed in to the device - not just this app.
Once an account is 'signed-in', every MSAL app on the device that support shared device mode will be able to retrieve this account, and use them to silently perform API calls.
'Sign-out' means that user will be signed out from the device - every MSAL apps and the default browser.
Method Summary
Modifier and Type | Method and Description |
---|---|
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 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. |
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(final CurrentAccountCallback callback)
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 |
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
Method Details
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.
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.
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)
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.
Returns:
getCurrentAccountAsync
public void getCurrentAccountAsync(final CurrentAccountCallback callback)
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.
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
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
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.
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.
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.
Parameters:
Applies to
Azure SDK for Java