You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-92Lines changed: 14 additions & 92 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,24 @@
6
6
7
7
## Overview
8
8
9
-
MSAL Android is a library that enables Android applications to authenticate users with Microsoft identity platform (formerly Azure Active Directory) and access protected web APIs using OAuth2 and OpenID Connect protocols. The Microsoft Authentication Library (MSAL) for Android enables developers to acquire security tokens from the Microsoft identity platform to authenticate users and access secure web APIs for their Android based applications.
9
+
MSAL Android is a library that enables Android applications to authenticate users with Microsoft identity platform and access protected web APIs using OAuth2 and OpenID Connect protocols. The Microsoft Authentication Library (MSAL) for Android enables developers to acquire security tokens from the Microsoft identity platform to authenticate users and access secure web APIs for their Android based applications.
10
10
11
11
MSAL Android supports multiple authentication scenarios, such as single sign-on (SSO), conditional access, and brokered authentication. MSAL Android also provides native authentication APIs that allow applications to implement a native experience with end-to-end customizable flows.
The Azure Active Directory Authentication Library (ADAL) for Android was deprecated on June 2023. Follow the [ADAL to MSAL migration guide for Android](https://docs.microsoft.com/azure/active-directory/develop/migrate-android-adal-msal) to avoid putting your app's security at risk..
18
-
19
15
## Getting started
20
16
21
17
To use MSAL Android in your application, you need to register your application in the Microsoft Entra Admin center and configure your Android project. Since MSAL Android supports both browser-delegated and native authentication experiences, follow the steps in the following tutorials based on your scenario.
22
18
23
-
* For browser-delegated scenarios, refer to the quickstart, [Sign in users and call Microsoft Graph from an Android app](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-mobile-app-android-sign-in).
19
+
* For browser-delegated authentication scenarios, refer to the quickstart, [Sign in users and call Microsoft Graph from an Android app](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-mobile-app-android-sign-in).
20
+
21
+
* For native authentication scenarios, refer to the Microsoft Entra External ID sample guide, [Run Android Kotlin sample app](https://review.learn.microsoft.com/en-us/entra/external-id/customers/tutorial-native-authentication-prepare-android-app?branch=release-native-auth-public-preview).
22
+
24
23
25
-
* For Native Authentication scenarios, refer to the Microsoft Entra External ID sample guide, [Run Android Kotlin sample app](https://review.learn.microsoft.com/en-us/entra/external-id/customers/tutorial-native-authentication-prepare-android-app?branch=release-native-auth-public-preview).
24
+
## Migrating from ADAL
26
25
26
+
The Azure Active Directory Authentication Library (ADAL) for Android was deprecated on June 2023. Follow the [ADAL to MSAL migration guide for Android](https://docs.microsoft.com/azure/active-directory/develop/migrate-android-adal-msal) to avoid putting your app's security at risk.
27
27
28
28
## Using MSAL Android
29
29
@@ -37,7 +37,7 @@ To use MSAL Android in your application, you need to register your application i
37
37
38
38
Add the following dependencies to your app's build.gradle:
39
39
40
-
**For browser-delegated authentication:**
40
+
**Browser-delegated authentication:**
41
41
42
42
```gradle
43
43
dependencies {
@@ -53,7 +53,7 @@ maven {
53
53
}
54
54
```
55
55
56
-
**For Native authentication:**
56
+
**Native authentication:**
57
57
58
58
59
59
```java
@@ -84,7 +84,7 @@ In the `redirect_uri`, the `<YOUR_PACKAGE_NAME>` refers to the package name retu
84
84
85
85
The values above are the minimum required configuration. MSAL relies on the defaults that ship with the library for all other settings. Please refer to the [MSAL Android configuration file documentation](https://learn.microsoft.com/en-us/entra/msal/android/msal-configuration) to understand the library defaults.
86
86
87
-
**For Native authentication:**
87
+
**Native authentication:**
88
88
89
89
1. Right-click res and choose New > Directory. Enter raw as the new directory name and select OK.
90
90
1. In this new folder (app > src > main > res > raw), create a new JSON file called auth_config_native_auth.json and paste the following template MSAL Configuration:
@@ -107,7 +107,7 @@ The values above are the minimum required configuration. MSAL relies on the def
107
107
}
108
108
```
109
109
110
-
### Step 3: Configure the AndroidManifest.xml
110
+
### Step 3: Configure the AndroidManifest.xml for browser-delegated authentication
111
111
112
112
1. Request the following permissions via the Android Manifest
113
113
@@ -138,90 +138,12 @@ The values above are the minimum required configuration. MSAL relies on the def
138
138
139
139
>NOTE: Please refer to the [frequently asked questions](https://learn.microsoft.com/en-us/entra/msal/android/frequently-asked-questions) for more information on common redirect uri issues.
140
140
141
-
### Step 4: Create an MSAL PublicClientApplication
142
-
143
-
>NOTE: In this example we are creating an instance of MultipleAccountPublicClientApplication, which is designed to work with apps that allow multiple accounts to be used within the same application. If you would like to use SingleAccount mode, refer to the [single vs. multi account documentation](https://docs.microsoft.com/azure/active-directory/develop/single-multi-account). You can also check out the [quickstart](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v2-android) for examples of how this is used.
144
-
145
-
1. Create a new MultipleAccountPublicClientApplication instance.
Before getting a token silently for the account used to previously acquire a token interactively, we recommend that you verify that the account is still present in the local cache or on the device in case of brokered auth
205
-
206
-
Let's use the synchronous methods here which can only be invoked from a Worker thread
### Step 4: Create an MSAL PublicClientApplication
219
143
220
-
//Use default authority to request token from pass null
221
-
IAuthenticationResult result = mMultipleAccountApp.acquireTokenSilent(newScopes, account, authority);
222
-
}
144
+
For browser-delegated authentication, you'll need to create an instance of the PublicClientApplication, before you can acquire a token silently or interactively. Please proceed to the official MSAL Android documentation on how to [instantiate your client application and acquire tokens](https://learn.microsoft.com/en-us/entra/msal/android/acquire-tokens)
223
145
224
-
```
146
+
For a native authentication experience, you can optionally complete [additional logging configuration](https://review.learn.microsoft.com/en-us/entra/external-id/customers/tutorial-native-authentication-prepare-android-app?branch=release-native-auth-public-preview#create-sdk-instance), and proceed to creating an instance of the client application using the configuration we created in step 2. Learn more by following the [Native auth Android app tutorial](https://review.learn.microsoft.com/en-us/entra/external-id/customers/tutorial-native-authentication-prepare-android-app?branch=release-native-auth-public-preview#create-sdk-instance)
225
147
226
148
## ProGuard
227
149
MSAL uses reflection and generic type information stored in `.class` files at runtime to support various persistence and serialization related functionalities. Accordingly, library support for minification and obfuscation is limited. A default configuration is shipped with this library; please [file an issue](https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/new/choose) if you find any issues.
0 commit comments