PublicClientApplication Class
- java.
lang. Object - IPublicClientApplication
- com.
microsoft. identity. client. PublicClientApplication
- com.
public class PublicClientApplication implements IPublicClientApplication,ITokenShare
This is the entry point for developer to create public native applications and make API calls to acquire tokens.
Client ID: The clientID of your application is a unique identifier which can be obtained from the app registration portal.
AuthorityMetadata: A URL indicating a directory that MSAL can use to obtain tokens. In Azure AD it is of the form https://<[nstance]/[tenant], where [instance] is the directory host (e.g. https://login.microsoftonline.com) and [tenant] is an identifier within the directory itself (e.g. a domain associated to the tenant, such as contoso.onmicrosoft.com, or the GUID representing the TenantID property of the directory)
For B2C, it is of the form https://[instance]/tfp/[tenant]/[policy] where instance and tenant are same as Azure AD, and [policy] is a string like signup
MSAL PublicClientApplication provides three constructors allowing the client id to be set either via AndroidManifest.xml metadata or using constructor parameters. Similarly, if developer chooses not to use the default authority https://login.microsoftonline.com, an alternate can also be configured using the manifest, constructor parameters, or in acquire token calls.
Redirect is auto-generated in the library in the format of msal<client-id>://auth, and it cannot be overridden.
Developer MUST have BrowserTabActivity declared in their manifest, which must have the correct intent-filter configured. If the wrong scheme and host is provided, the sdk will fail the PublicClientApplication creation.
Expected format will be:
<activityandroid:name="com.microsoft.identity.client.BrowserTabActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="msal&lt;AppClientId&gt;" android:host="auth" /> </intent-filter>
</activity>
Other Terminology:
Scopes:Permissions that the developers wants included in the access token received . Not all scopes are guaranteed to be included in the access token returned.
Login Hint: Usually an email, to pass to the service at the beginning of the interactive authentication flow.
Extra Scopes to Consent: Permissions you want the user to consent to in the same authentication flow, but won't be included in the returned access token.
Field Summary
Modifier and Type | Field and Description |
---|---|
Public |
homeAccountMatcher |
Public |
localAccountMatcher |
Public |
mPublicClientConfiguration |
TokenShareUtility | mTokenShareUtility |
Public |
usernameMatcher |
Constructor Summary
Constructor | Description | |
---|---|---|
PublicClientApplication(@NonNull final PublicClientApplicationConfiguration configFile) |
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. |
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(@Nullable String[] scopes, @NonNull final DeviceCodeFlowCallback callback) |
Acquire |
buildAcquireTokenSilentParameters(@NonNull final String[] scopes, @NonNull final IAccount account, @NonNull final String authority, final boolean forceRefresh, @Nullable final ClaimsRequest claimsRequest, @NonNull final SilentAuthenticationCallback callback) |
void |
create(@NonNull final Context context, @NonNull final File configFile, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, File, ApplicationCreatedListener) will read the client id and other configuration settings from the specified file. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki |
void |
create(@NonNull final Context context, @NonNull final String clientId, @Nullable final String authority, @NonNull final String redirectUri, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, String, String, ApplicationCreatedListener) allows the client id and authority to be passed instead of providing them through metadata. Note: The Context should be the application context instead of an running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. |
IPublic |
create(@NonNull final Context context, final int configFileResourceId)
PublicClientApplication#create(Context, int, ApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
void |
create(@NonNull final Context context, final int configFileResourceId, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, int, ApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
IMultiple |
createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, File) will read the client id and other configuration settings from the file included in your application resources. This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true) Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki |
void |
createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile, @NonNull final IMultipleAccountApplicationCreatedListener listener)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, File, IMultipleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources. This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true) Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
IMultiple |
createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final int configFileResourceId)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your application's resources. This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true) Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
void |
createMultipleAccountPublicClientApplication(@NonNull final Context context, final int configFileResourceId, @NonNull final IMultipleAccountApplicationCreatedListener listener)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, int, IMultipleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources. This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true) Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
void |
createSingleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile, @NonNull final ISingleAccountApplicationCreatedListener listener)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int, ISingleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources. This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki |
ISingle |
createSingleAccountPublicClientApplication( @NonNull final Context context, @Nullable final File configFile)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your applications resources. This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki |
ISingle |
createSingleAccountPublicClientApplication( @NonNull final Context context, final int configFileResourceId)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your application's resources. This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
void |
createSingleAccountPublicClientApplication(@NonNull final Context context, final int configFileResourceId, @NonNull final ISingleAccountApplicationCreatedListener listener)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int, ISingleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources. This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single. Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs. For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki |
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. |
CommandCallback | getCommandCallback( @NonNull final SilentAuthenticationCallback authenticationCallback, @NonNull final TokenParameters tokenParameters) |
Public |
getConfiguration()
Returns the PublicClientConfiguration for this instance of PublicClientApplication. |
String | getMsaFamilyRefreshToken(@NonNull final String identifier) |
Token |
getMsaFamilyRefreshTokenWithMetadata(@NonNull final String identifier) |
String | getOrgIdFamilyRefreshToken(@NonNull final String identifier) |
Token |
getOrgIdFamilyRefreshTokenWithMetadata(@NonNull final String identifier) |
String | getSdkVersion() |
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 |
void |
postAuthResult(@NonNull final ILocalAuthenticationResult localAuthenticationResult, @NonNull final TokenParameters requestParameters, @NonNull final SilentAuthenticationCallback authenticationCallback)
Helper method to post authentication result. |
void | saveMsaFamilyRefreshToken(@NonNull final String refreshToken) |
void | saveOrgIdFamilyRefreshToken(@NonNull final String ssoStateSerializerBlob) |
void |
showExpectedMsalRedirectUriInfo(Activity activity)
Presents an activity that includes the package name, signature, redirect URI and manifest entry required for your application |
void | validateAcquireTokenParameters(AcquireTokenParameters parameters) |
void | validateAcquireTokenSilentParameters(AcquireTokenSilentParameters parameters) |
Inherited Members
Field Details
homeAccountMatcher
protected AccountMatcher homeAccountMatcher= new AccountMatcher() { @Override boolean matches(@NonNull final String homeAccountId, @NonNull final IAccount account) { return homeAccountId.contains(account.getId()); } }
localAccountMatcher
protected AccountMatcher localAccountMatcher= new AccountMatcher() {
@Override
boolean matches(@NonNull final String localAccountId,
@NonNull final IAccount account) {
if (localAccountId.contains(account.getId())) {
return true;
} else if (account instanceof MultiTenantAccount) {
final MultiTenantAccount multiTenantAccount = (MultiTenantAccount) account;
final Map
mPublicClientConfiguration
protected PublicClientApplicationConfiguration mPublicClientConfiguration
mTokenShareUtility
protected TokenShareUtility mTokenShareUtility
usernameMatcher
protected AccountMatcher usernameMatcher
Constructor Details
PublicClientApplication
protected PublicClientApplication(@NonNull final PublicClientApplicationConfiguration configFile)
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:
PublicClientApplication.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:
PublicClientApplication.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:
PublicClientApplication.acquireTokenSilent( @NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)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:
PublicClientApplication.acquireTokenSilentAsync( @NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters)Parameters:
acquireTokenWithDeviceCode
public void acquireTokenWithDeviceCode(@Nullable String[] scopes, @NonNull final DeviceCodeFlowCallback callback)
Parameters:
buildAcquireTokenSilentParameters
protected AcquireTokenSilentParameters buildAcquireTokenSilentParameters(@NonNull final String[] scopes, @NonNull final IAccount account, @NonNull final String authority, final boolean forceRefresh, @Nullable final ClaimsRequest claimsRequest, @NonNull final SilentAuthenticationCallback callback)
Parameters:
create
public static void create(@NonNull final Context context, @NonNull final File configFile, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, File, ApplicationCreatedListener) will read the client id and other configuration settings from the specified file.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki
Parameters:
create
public static void create(@NonNull final Context context, @NonNull final String clientId, @Nullable final String authority, @NonNull final String redirectUri, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, String, String, ApplicationCreatedListener) allows the client id and authority to be passed instead of providing them through metadata.
Note: The Context should be the application context instead of an running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
Parameters:
create
public static IPublicClientApplication create(@NonNull final Context context, final int configFileResourceId)
PublicClientApplication#create(Context, int, ApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
Returns:
Throws:
create
public static void create(@NonNull final Context context, final int configFileResourceId, @NonNull final ApplicationCreatedListener listener)
PublicClientApplication#create(Context, int, ApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
createMultipleAccountPublicClientApplication
public static IMultipleAccountPublicClientApplication createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, File) will read the client id and other configuration settings from the file included in your application resources.
This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true)
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki
Parameters:
Throws:
createMultipleAccountPublicClientApplication
public static void createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile, @NonNull final IMultipleAccountApplicationCreatedListener listener)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, File, IMultipleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources.
This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true)
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
createMultipleAccountPublicClientApplication
public static IMultipleAccountPublicClientApplication createMultipleAccountPublicClientApplication(@NonNull final Context context, @NonNull final int configFileResourceId)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your application's resources.
This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true)
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
Returns:
Throws:
createMultipleAccountPublicClientApplication
public static void createMultipleAccountPublicClientApplication(@NonNull final Context context, final int configFileResourceId, @NonNull final IMultipleAccountApplicationCreatedListener listener)
PublicClientApplication#createMultipleAccountPublicClientApplication(Context, int, IMultipleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources.
This function will pass back an MsalClientException object if it is unable to return IMultipleAccountPublicClientApplication. For example, when the device is marked as 'shared' (isSharedDevice() is set to true)
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
createSingleAccountPublicClientApplication
public static void createSingleAccountPublicClientApplication(@NonNull final Context context, @NonNull final File configFile, @NonNull final ISingleAccountApplicationCreatedListener listener)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int, ISingleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application resources.
This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki
Parameters:
createSingleAccountPublicClientApplication
public static ISingleAccountPublicClientApplication createSingleAccountPublicClientApplication( @NonNull final Context context, @Nullable final File configFile)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your applications resources.
This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL configuration file, please see Android app resource overview and MSAL Github Wiki
Parameters:
Returns:
Throws:
createSingleAccountPublicClientApplication
public static ISingleAccountPublicClientApplication createSingleAccountPublicClientApplication( @NonNull final Context context, final int configFileResourceId)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int) will read the client id and other configuration settings from the file included in your application's resources.
This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
Returns:
Throws:
createSingleAccountPublicClientApplication
public static void createSingleAccountPublicClientApplication(@NonNull final Context context, final int configFileResourceId, @NonNull final ISingleAccountApplicationCreatedListener listener)
PublicClientApplication#createSingleAccountPublicClientApplication(Context, int, ISingleAccountApplicationCreatedListener) will read the client id and other configuration settings from the file included in your application's resources.
This function will pass back an MsalClientException object if it is unable to return ISingleAccountApplicationCreatedListener. For example, AccountMode in configuration is not set to single.
Note: The Context should be the application context instead of the running activity's context, which could potentially make the sdk hold a strong reference to the activity, thus preventing correct garbage collection and causing bugs.
For more information on the schema of the MSAL config json, please see Android app resource overview and MSAL Github Wiki
Parameters:
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.
Overrides:
PublicClientApplication.generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters)Parameters:
Returns:
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.
Overrides:
PublicClientApplication.generateSignedHttpRequest(@NonNull final IAccount account, @NonNull final PoPAuthenticationScheme popParameters, @NonNull final SignedHttpRequestRequestCallback callback)Parameters:
getCommandCallback
protected CommandCallback getCommandCallback( @NonNull final SilentAuthenticationCallback authenticationCallback, @NonNull final TokenParameters tokenParameters)
Parameters:
getConfiguration
public PublicClientApplicationConfiguration getConfiguration()
Returns the PublicClientConfiguration for this instance of PublicClientApplication.
Overrides:
PublicClientApplication.getConfiguration()Returns:
getMsaFamilyRefreshToken
public String getMsaFamilyRefreshToken(@NonNull final String identifier)
Parameters:
getMsaFamilyRefreshTokenWithMetadata
public TokenShareResult getMsaFamilyRefreshTokenWithMetadata(@NonNull final String identifier)
Parameters:
getOrgIdFamilyRefreshToken
public String getOrgIdFamilyRefreshToken(@NonNull final String identifier)
Parameters:
getOrgIdFamilyRefreshTokenWithMetadata
public TokenShareResult getOrgIdFamilyRefreshTokenWithMetadata(@NonNull final String identifier)
Parameters:
getSdkVersion
public static String getSdkVersion()
Returns:
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
Overrides:
PublicClientApplication.isSharedDevice()postAuthResult
protected void postAuthResult(@NonNull final ILocalAuthenticationResult localAuthenticationResult, @NonNull final TokenParameters requestParameters, @NonNull final SilentAuthenticationCallback authenticationCallback)
Helper method to post authentication result.
Parameters:
saveMsaFamilyRefreshToken
public void saveMsaFamilyRefreshToken(@NonNull final String refreshToken)
Parameters:
saveOrgIdFamilyRefreshToken
public void saveOrgIdFamilyRefreshToken(@NonNull final String ssoStateSerializerBlob)
Parameters:
showExpectedMsalRedirectUriInfo
public static void showExpectedMsalRedirectUriInfo(Activity activity)
Presents an activity that includes the package name, signature, redirect URI and manifest entry required for your application
Parameters:
validateAcquireTokenParameters
protected void validateAcquireTokenParameters(AcquireTokenParameters parameters)
Parameters:
validateAcquireTokenSilentParameters
protected void validateAcquireTokenSilentParameters(AcquireTokenSilentParameters parameters)
Parameters:
Applies to
Azure SDK for Java