Microsoft Entra ID
Authentication

Quickstart Native Authentication Android Call Api

In brief

The quickstart for configuring a sample Android Kotlin app to call an ASP.NET Core web API was removed, including app registration, API permissions, sample deployment, and app configuration steps.

What Entra admins need to know

Administrators supporting this External ID sample can no longer rely on this page for those setup instructions. No action or deadline is stated.

This editorial summary was generated by AI from the documentation changes. Verify important details in the full Microsoft Learn article.

Documentation change

The comparison below shows only the changed extract. Use the full-page view for complete context.

deleted file mode 100644

title: Call a web API in a sample Android mobile app description: Learn how to call web API in an Android (Kotlin) sample app.

manager: pmwongera

ms.service: identity-platform

ms.subservice: external ms.topic: quickstart ms.date: 08/21/2024 ms.custom: #Customer intent: As a developer, I want to call a web API from a sample Android mobile app so that I can experience how Microsoft Entra's native authentication works.

Sign in users and call an API in a sample Android app by using native authentication

[!INCLUDE applies-to-external-only]

In this quickstart you learn how to configure a sample Android mobile application to call an ASP.NET Core web API.

Prerequisites

Configure API scopes

[!INCLUDE add-api-scopes]

Configure app roles

[!INCLUDE add-app-role]

Configure optional claims

[!INCLUDE add-optional-claims-access]

Grant API permissions to the Android sample app

Once you've registered both your client app and web API and you've exposed the API by creating scopes, you can configure the client's permissions to the API by following these steps:

[!INCLUDE grant-api-permission-call-api-common]

Clone or download sample web API

To obtain the sample application, you can either clone it from GitHub or download it as a .zip file.

  • To clone the sample, open a command prompt and navigate to where you wish to create the project, and enter the following command:

    git clone https://github.com/Azure-Samples/ms-identity-ciam-dotnet-tutorial.git
    
  • Download the .zip file. Extract it to a file path where the length of the name is fewer than 260 characters.

Configure and run sample web API

  1. In your code editor, open 2-Authorization/1-call-own-api-aspnet-core-mvc/ToDoListAPI/appsettings.json file.

  2. Find the placeholder:

    • Enter_the_Application_Id_Here and replace it with the Application (client) ID of the web API you copied earlier.
    • Enter_the_Tenant_Id_Here and replace it with the Directory (tenant) ID you copied earlier.
    • Enter_the_Tenant_Subdomain_Here and replace it with the Directory (tenant) subdomain. For example, if your tenant primary domain is contoso.onmicrosoft.com, use contoso. If you don't have your tenant name, learn how to read your tenant details.

You need to host your web API for the Android sample app to call it. Follow Quickstart: Deploy an ASP.NET web app to deploy your web API.

Configure sample Android mobile app to call web API

The sample allows you to configure multiple Web API URL endpoints and sets of scopes. In this case, you configure only one Web API URL endpoint and its associated scopes.

  1. In your Android Studio, open /app/src/main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/AccessApiFragment.kt file.

  2. Find property named WEB_API_URL_1 and set the URL to your web API.

    private const val WEB_API_URL_1 = "" // Developers should set the respective URL of their web API here
    
  3. Find property named scopesForAPI1 and set the scopes recorded in Grant API permissions to the Android sample app.

    private val scopesForAPI1 = listOf<String>() // Developers should set the respective scopes of their web API here. For example, private val scopes = listOf<String>("api://{clientId}/{ToDoList.Read}", "api://{clientId}/{ToDoList.ReadWrite}")
    

Run Android sample app and call web API

To build and run your app, follow these steps:

  1. In the toolbar, select your app from the run configurations menu.

  2. In the target device menu, select the device that you want to run your app on.

    If you don't have any devices configured, you need to either create an Android Virtual Device to use the Android Emulator or connect a physical device.

  3. Select Run button. The app opens on the email and one-time passcode screen.

  4. Select the API tab to test the API call. A successful call to the web API returns HTTP 200, while HTTP 403 signifies unauthorized access.

Next steps

[!div class="nextstepaction"] Tutorial: Prepare your Android app for native authentication.

Daily Entra.News

Get daily email updates

Get a concise summary of the latest Microsoft Entra updates delivered straight to your inbox.

Loading the secure signup form…