public class SingleAccountPublicClientApplication extends PublicClientApplication implements ISingleAccountPublicClientApplication
PublicClientApplication.BrokerDeviceModeCallbackISingleAccountPublicClientApplication.CurrentAccountCallback, ISingleAccountPublicClientApplication.SignOutCallbackIPublicClientApplication.ApplicationCreatedListener, IPublicClientApplication.DeviceCodeFlowCallback, IPublicClientApplication.IMultipleAccountApplicationCreatedListener, IPublicClientApplication.ISingleAccountApplicationCreatedListener, IPublicClientApplication.LoadAccountsCallback, IPublicClientApplication.SignedHttpRequestRequestCallback| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CURRENT_ACCOUNT_SHARED_PREFERENCE_KEY
SharedPreference key for storing current account.
|
static java.lang.String |
SINGLE_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES
Name of the shared preference cache for storing SingleAccountPublicClientApplication data.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquireToken(AcquireTokenParameters acquireTokenParameters)
Acquire token interactively, will pop-up webUI.
|
void |
acquireToken(android.app.Activity activity,
java.lang.String[] scopes,
AuthenticationCallback callback)
Acquire token interactively, will pop-up webUI.
|
IAuthenticationResult |
acquireTokenSilent(AcquireTokenSilentParameters acquireTokenSilentParameters)
Perform acquire token silent call.
|
IAuthenticationResult |
acquireTokenSilent(java.lang.String[] scopes,
java.lang.String authority)
Perform acquire token silent call.
|
void |
acquireTokenSilentAsync(AcquireTokenSilentParameters acquireTokenSilentParameters)
Perform acquire token silent call.
|
void |
acquireTokenSilentAsync(java.lang.String[] scopes,
java.lang.String authority,
SilentAuthenticationCallback callback)
Perform acquire token silent call.
|
ICurrentAccountResult |
getCurrentAccount()
Gets the current account and notify if the current account changes.
|
void |
getCurrentAccountAsync(ISingleAccountPublicClientApplication.CurrentAccountCallback callback)
Gets the current account and notify if the current account changes.
|
void |
signIn(android.app.Activity activity,
java.lang.String loginHint,
java.lang.String[] scopes,
AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts.
|
void |
signIn(android.app.Activity activity,
java.lang.String loginHint,
java.lang.String[] scopes,
Prompt prompt,
AuthenticationCallback callback)
Allows a user to sign in to your application with one of their accounts.
|
void |
signInAgain(android.app.Activity activity,
java.lang.String[] scopes,
Prompt prompt,
AuthenticationCallback callback)
Reauthorizes the current account according to the supplied scopes and prompt behavior.
|
boolean |
signOut()
Signs out the current the Account and Credentials (tokens).
|
void |
signOut(ISingleAccountPublicClientApplication.SignOutCallback callback)
Signs out the current the Account and Credentials (tokens).
|
acquireTokenWithDeviceCode, create, create, create, create, createMultipleAccountPublicClientApplication, createMultipleAccountPublicClientApplication, createMultipleAccountPublicClientApplication, createMultipleAccountPublicClientApplication, createSingleAccountPublicClientApplication, createSingleAccountPublicClientApplication, createSingleAccountPublicClientApplication, createSingleAccountPublicClientApplication, generateSignedHttpRequest, generateSignedHttpRequest, getConfiguration, getMsaFamilyRefreshToken, getMsaFamilyRefreshTokenWithMetadata, getOrgIdFamilyRefreshToken, getOrgIdFamilyRefreshTokenWithMetadata, getSdkVersion, isSharedDevice, saveMsaFamilyRefreshToken, saveOrgIdFamilyRefreshToken, showExpectedMsalRedirectUriInfoequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacquireTokenWithDeviceCode, generateSignedHttpRequest, generateSignedHttpRequest, getConfiguration, isSharedDevicepublic static final java.lang.String SINGLE_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES
public static final java.lang.String CURRENT_ACCOUNT_SHARED_PREFERENCE_KEY
public void getCurrentAccountAsync(ISingleAccountPublicClientApplication.CurrentAccountCallback callback)
ISingleAccountPublicClientApplicationgetCurrentAccountAsync in interface ISingleAccountPublicClientApplicationcallback - a callback to be invoked when the operation finishes.public ICurrentAccountResult getCurrentAccount() throws java.lang.InterruptedException, MsalException
ISingleAccountPublicClientApplicationgetCurrentAccount in interface ISingleAccountPublicClientApplicationjava.lang.InterruptedExceptionMsalExceptionpublic void signIn(android.app.Activity activity,
java.lang.String loginHint,
java.lang.String[] scopes,
AuthenticationCallback callback)
ISingleAccountPublicClientApplicationISingleAccountPublicClientApplication.signInAgain(Activity, String[], Prompt, AuthenticationCallback) or
IPublicClientApplication.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
signIn in interface ISingleAccountPublicClientApplicationactivity - Non-null Activity that is used as the parent activity for launching the com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity.loginHint - Optional. If provided, will be used as the query parameter sent for authenticating the user,
which will have the UPN pre-populated.scopes - The non-null array of scopes to be consented to during sign in.
MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
The access token returned is for MS Graph and will allow you to query for additional information about the signed in account.callback - AuthenticationCallback that is used to send the result back. The success result will be
sent back via SilentAuthenticationCallback.onSuccess(IAuthenticationResult).
Failure case will be sent back via {public void signIn(android.app.Activity activity,
java.lang.String loginHint,
java.lang.String[] scopes,
Prompt prompt,
AuthenticationCallback callback)
ISingleAccountPublicClientApplicationISingleAccountPublicClientApplication.signInAgain(Activity, String[], Prompt, AuthenticationCallback) or
IPublicClientApplication.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
signIn in interface ISingleAccountPublicClientApplicationactivity - Non-null Activity that is used as the parent activity for launching the com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity.loginHint - Optional. If provided, will be used as the query parameter sent for authenticating the user,
which will have the UPN pre-populated.scopes - The non-null array of scopes to be consented to during sign in.
MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
The access token returned is for MS Graph and will allow you to query for additional information about the signed in account.callback - AuthenticationCallback that is used to send the result back. The success result will be
sent back via SilentAuthenticationCallback.onSuccess(IAuthenticationResult).
Failure case will be sent back via {public void signInAgain(android.app.Activity activity,
java.lang.String[] scopes,
Prompt prompt,
AuthenticationCallback callback)
ISingleAccountPublicClientApplicationNote: 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.
signInAgain in interface ISingleAccountPublicClientApplicationactivity - 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 consented to during sign in.
MSAL always sends the scopes 'openid profile offline_access'. Do
not include any of these scopes in the scope parameter. The access
token returned is for MS Graph and will allow you to query for
additional information about the signed in account.prompt - Nullable. Indicates the type of user interaction that is required.
If no argument is supplied the default behavior will be used.callback - AuthenticationCallback that is used to send the result back.
The success result will be sent back via
SilentAuthenticationCallback.onSuccess(IAuthenticationResult).
Failure case will be sent back via SilentAuthenticationCallback.onError(MsalException).public void signOut(ISingleAccountPublicClientApplication.SignOutCallback callback)
ISingleAccountPublicClientApplicationsignOut in interface ISingleAccountPublicClientApplicationcallback - a callback to be invoked when the operation finishes.public boolean signOut()
throws MsalException,
java.lang.InterruptedException
ISingleAccountPublicClientApplicationsignOut in interface ISingleAccountPublicClientApplicationMsalExceptionjava.lang.InterruptedExceptionpublic void acquireToken(android.app.Activity activity,
java.lang.String[] scopes,
AuthenticationCallback callback)
IPublicClientApplicationPrompt is Prompt.SELECT_ACCOUNT.acquireToken in interface IPublicClientApplicationacquireToken in class PublicClientApplicationactivity - 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 AuthenticationCallback.onCancel().
2) If the sdk successfully receives the token back, result will be sent back via
SilentAuthenticationCallback.onSuccess(IAuthenticationResult)
3) All the other errors will be sent back via
SilentAuthenticationCallback.onError(MsalException).public void acquireToken(AcquireTokenParameters acquireTokenParameters)
IPublicClientApplicationPrompt is Prompt.SELECT_ACCOUNT.
Convey parameters via the AquireTokenParameters object
acquireToken in interface IPublicClientApplicationacquireToken in class PublicClientApplicationpublic void acquireTokenSilentAsync(java.lang.String[] scopes,
java.lang.String authority,
SilentAuthenticationCallback callback)
ISingleAccountPublicClientApplicationacquireTokenSilentAsync in interface ISingleAccountPublicClientApplicationscopes - 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.authority - Authority to issue the token.callback - SilentAuthenticationCallback that is used to send the result back. The success result will be
sent back via SilentAuthenticationCallback.onSuccess(IAuthenticationResult).
Failure case will be sent back via {public IAuthenticationResult acquireTokenSilent(java.lang.String[] scopes, java.lang.String authority) throws MsalException, java.lang.InterruptedException
ISingleAccountPublicClientApplicationacquireTokenSilent in interface ISingleAccountPublicClientApplicationscopes - 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.authority - Authority to issue the token.MsalExceptionjava.lang.InterruptedExceptionpublic void acquireTokenSilentAsync(AcquireTokenSilentParameters acquireTokenSilentParameters)
IPublicClientApplicationacquireTokenSilentAsync in interface IPublicClientApplicationacquireTokenSilentAsync in class PublicClientApplicationpublic IAuthenticationResult acquireTokenSilent(AcquireTokenSilentParameters acquireTokenSilentParameters) throws java.lang.InterruptedException, MsalException
IPublicClientApplicationacquireTokenSilent in interface IPublicClientApplicationacquireTokenSilent in class PublicClientApplicationjava.lang.InterruptedExceptionMsalException