Skip to content

Commit 670ccc0

Browse files
Update SDK with native authentication content
1 parent 2dc7974 commit 670ccc0

1 file changed

Lines changed: 62 additions & 16 deletions

File tree

README.md

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
Microsoft Authentication Library (MSAL) for Android
2-
==============================================
1+
# Microsoft Authentication Library (MSAL) for Android
32

4-
|[📚Documentation](https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-android) | [ 🚀 Getting Started](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-mobile-app-android-sign-in) | [💻 Sample Code](https://github.com/AzureAD/microsoft-authentication-library-for-android/wiki/MSAL-Code-Samples)| [ 📖 Library Reference](http://javadoc.io/doc/com.microsoft.identity.client/msal) | [🛠️ Support](README.md#community-help-and-support) | [🌐 Docs Site](https://learn.microsoft.com/en-us/azure/active-directory/develop/scenario-mobile-overview)
5-
| --- | --- | --- | --- | --- | --- |
3+
| Documentation | Sample Code | Library Reference | Support |
4+
|-------------------------------|---------------------------|-------------------|---------|
5+
| [MSAL Android documentation](https://learn.microsoft.com/en-us/entra/msal/android/) <br/> [Workforce apps tutorials](https://learn.microsoft.com/en-us/entra/identity-platform/tutorial-v2-android)<br/> Customer apps tutorials <br/> • Browser-delegated <br/>• Native Authentication | [Workforce samples](https://learn.microsoft.com/en-us/entra/identity-platform/sample-v2-code?tabs=apptype#mobile) <br/> [Customer samples](https://learn.microsoft.com/en-us/entra/identity-platform/sample-v2-code?tabs=apptype#mobile) | [ MSAL Android reference](http://javadoc.io/doc/com.microsoft.identity.client/msal) | 🛠️ |
6+
| --- | --- | --- | --- |
67

8+
## Overview
79

8-
## Introduction
9-
The Microsoft Authentication Library (MSAL) for Android enables developers to acquire security tokens from the Microsoft identity platform to authenticate users and access secured web APIs for their Android based applications.
10-
The MSAL library for Android gives your app the ability to use the [Microsoft Cloud](https://cloud.microsoft.com) by supporting [Microsoft Azure Active Directory](https://azure.microsoft.com/services/active-directory/) and [Microsoft Personal Accounts](https://account.microsoft.com) using industry standard OAuth2 and OpenID Connect. The library also supports [Azure AD B2C](https://azure.microsoft.com/services/active-directory-b2c/).
10+
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.
11+
12+
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.
1113

1214
[![Version Badge](https://img.shields.io/maven-central/v/com.microsoft.identity.client/msal.svg)](https://repo1.maven.org/maven2/com/microsoft/identity/client/msal/)
1315

14-
### :exclamation: Migrating from ADAL
16+
## Migrating from ADAL
1517

16-
ADAL Android was deprecated on June 2023. We do not support ADAL. See the [ADAL to MSAL migration guide for Android](https://docs.microsoft.com/azure/active-directory/develop/migrate-android-adal-msal)
18+
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..
1719

18-
## Using MSAL
20+
## Getting started
1921

20-
- Before you can get a token from Azure AD v2.0 or Azure AD B2C, you'll need to register an application. To register your app, use [the Azure portal](https://aka.ms/AppRegistrations). For Azure AD B2C, checkout [how to register your app with B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-app-registration).
22+
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.
23+
• For browser-delegated scenarios, refere 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)
24+
• 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/how-to-run-sample-android-app?branch=pr-en-us-2021#register-an-application)
25+
26+
27+
## Using MSAL Android
2128

2229
### Requirements
2330

@@ -27,7 +34,9 @@ ADAL Android was deprecated on June 2023. We do not support ADAL. See the [ADAL
2734

2835
### Step 1: Declare dependency on MSAL
2936

30-
Add to your app's build.gradle:
37+
Add the following dependencies to your app's build.gradle:
38+
39+
**For browser-delegated authentication**
3140

3241
```gradle
3342
dependencies {
@@ -43,11 +52,25 @@ maven {
4352
}
4453
```
4554

55+
**For Native Authentication**
56+
57+
58+
```java
59+
dependencies {
60+
implementation 'com.microsoft.identity.client:msal:5.1.0'
61+
}
62+
maven {
63+
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
64+
name 'Duo-SDK-Feed'
65+
}
66+
```
67+
4668
### Step 2: Create your MSAL configuration file
4769

48-
[Configuration Documentation](https://docs.microsoft.com/azure/active-directory/develop/msal-configuration)
70+
**Browser-delegated Authentication:**
71+
72+
It's simplest to create your configuration file as a "raw" resource file in your project resources. You'll be able to refer to this using the generated resource identifier when constructing an instance of PublicClientApplication. If you are registering your app in the portal for the first time, you will also be provided with the detailed MSAL [Android configuration file](https://learn.microsoft.com/en-us/entra/msal/android/msal-configuration)
4973

50-
It's simplest to create your configuration file as a "raw" resource file in your project resources. You'll be able to refer to this using the generated resource identifier when constructing an instance of PublicClientApplication. If you are registering your app in the portal for the first time, you will also be provided with this config JSON.
5174

5275
```javascript
5376
{
@@ -59,7 +82,30 @@ It's simplest to create your configuration file as a "raw" resource file in your
5982

6083
>NOTE: In the `redirect_uri`, the part `<YOUR_PACKAGE_NAME>` refers to the package name returned by the `context.getPackageName()` method. This package name is the same as the [`application_id`](https://developer.android.com/studio/build/application-id) defined in your `build.gradle` file.
6184
62-
>NOTE: This is the minimum required configuration. MSAL relies on the defaults that ship with the library for all other settings. Please refer to the [configuration file documentation](https://docs.microsoft.com/azure/active-directory/develop/msal-configuration) to understand the library defaults.
85+
>NOTE: This is the minimum required configuration. MSAL relies on the defaults that ship with the library for all other settings. Please refer to the [configuration file documentation](https://learn.microsoft.com/en-us/entra/msal/android/msal-configuration) to understand the library defaults.
86+
87+
**For Native Authentication:**
88+
89+
1. Right-click res and choose New > Directory. Enter raw as the new directory name and select OK.
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:
91+
92+
```
93+
{
94+
"client_id": "Enter_the_Application_Id_Here",
95+
"authorities": [
96+
{
97+
"type": "CIAM",
98+
"authority_url": "https://Enter_the_Tenant_Subdomain_Here.ciamlogin.com/Enter_the_Tenant_Subdomain_Here.onmicrosoft.com/"
99+
}
100+
],
101+
"challenge_types": ["oob"],
102+
"logging": {
103+
"pii_enabled": false,
104+
"log_level": "INFO",
105+
"logcat_enabled": true
106+
}
107+
}
108+
```
63109

64110
### Step 3: Configure the AndroidManifest.xml
65111

@@ -90,7 +136,7 @@ It's simplest to create your configuration file as a "raw" resource file in your
90136
</activity>
91137
```
92138

93-
>NOTE: Please refer to [this FAQ](https://github.com/AzureAD/microsoft-authentication-library-for-android/wiki/MSAL-FAQ#redirect-uri-issues) for more information on common redirect uri issues.
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.
94140
95141
### Step 4: Create an MSAL PublicClientApplication
96142

0 commit comments

Comments
 (0)