Quickstart Native Authentication Ios Call Api
In brief
The documentation page covering iOS native authentication, API registration, permissions, sample API configuration, and API calls was deleted.
What Entra admins need to know
Administrators relying on this quickstart will no longer have its setup guidance available.
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: Sign in users and call an API in sample iOS mobile app by using native authentication
description: Learn how sign in users and call an API in sample iOS (Swift) mobile app by using native authentication
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 aim to learn registering a web API, configuring API scopes, roles, optional claims, and calling a web API in an iOS sample app.
Sign in users and call an API in sample iOS mobile app by using native authentication
[!INCLUDE applies-to-external-only]
In this quickstart you learn how to configure iOS sample application to call an ASP.NET Core web API.
Prerequisites
Sign in users in sample iOS (Swift) mobile app by using native authentication.Register a new application in the Microsoft Entra admin center for your web API, configured forAccounts in any organizational directory and personal Microsoft accounts. Refer to Register an application for more details. Record the following values from the applicationOverviewpage for later use:Application (client) IDDirectory (tenant) ID
Register a web API application
[!INCLUDE register-api-app]
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 iOS 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.gitDownload 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
In your code editor, open2-Authorization/1-call-own-api-aspnet-core-mvc/ToDoListAPI/appsettings.jsonfile.Find the placeholder:Enter_the_Application_Id_Hereand replace it with theApplication (client) IDof the web API you copied earlier.Enter_the_Tenant_Id_Hereand replace it with theDirectory (tenant) IDyou copied earlier.Enter_the_Tenant_Subdomain_Hereand replace it with the Directory (tenant) subdomain. For example, if your tenant primary domain iscontoso.onmicrosoft.com, usecontoso. If you don't have your tenant name, learn how to read your tenant details.
You need to host your web API for the iOS sample app to call it. Follow Quickstart: Deploy an ASP.NET web app to deploy your web API.
Configure sample iOS 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.
In your Xcode, open/NativeAuthSampleApp/ProtectedAPIViewController.swiftfile. If you're using macOS, here's a sample ProtectedAPIViewController.swift code file.FindprotectedAPIUrl1and enter your web API URL as its value.let protectedAPIUrl1: String? = nil // Developers should set the respective URL of their web API here. For example let protectedAPIUrl1: String? = "https://api.example.com/v1/resource"FindprotectedAPIScopes1and set the scopes recorded in Grant API permissions to the iOS sample app.let protectedAPIScopes1: [String] = [] // Developers should set the respective scopes of their web API here.For example, let protectedAPIScopes = ["api://{clientId}/{ToDoList.Read}","api://{clientId}/{ToDoList.ReadWrite}"]
Run iOS sample app and call web API
To build and run your app, follow these steps:
To build and run your code, selectRunfrom theProductmenu in Xcode. After a successful build, Xcode will launch the sample app in the Simulator.Select the API tab to test the API call. A successful call to the web API returns HTTP200, while HTTP403signifies unauthorized access.
Next steps
[!div class="nextstepaction"] Tutorial: Prepare your iOS app for native authentication.
@@ -1,101 +0,0 @@-----title: Sign in users and call an API in sample iOS mobile app by using native authentication-description: Learn how sign in users and call an API in sample iOS (Swift) mobile app by using native authentication--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 aim to learn registering a web API, configuring API scopes, roles, optional claims, and calling a web API in an iOS sample app.------# Sign in users and call an API in sample iOS mobile app by using native authentication--[!INCLUDE [applies-to-external-only](../external-id/includes/applies-to-external-only.md)]--In this quickstart you learn how to configure iOS sample application to call an ASP.NET Core web API.--## Prerequisites--* [Sign in users in sample iOS (Swift) mobile app by using native authentication](quickstart-native-authentication-ios-sign-in.md).-* Register a new application in the [Microsoft Entra admin center](https://entra.microsoft.com) for your web API, configured for *Accounts in any organizational directory and personal Microsoft accounts*. Refer to [Register an application](quickstart-register-app.md) for more details. Record the following values from the application **Overview** page for later use:- * Application (client) ID - * Directory (tenant) ID--### Register a web API application--[!INCLUDE [register-api-app](../external-id/customers/includes/register-app/register-api-app.md)]--### Configure API scopes--[!INCLUDE [add-api-scopes](../external-id/customers/includes/register-app/add-api-scopes.md)]--### Configure app roles--[!INCLUDE [add-app-role](../external-id/customers/includes/register-app/add-app-role.md)]--### Configure optional claims--[!INCLUDE [add-optional-claims-access](../external-id/customers/includes/register-app/add-optional-claims-access.md)]--## Grant API permissions to the iOS 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](../external-id/customers/includes/register-app/grant-api-permission-call-api-common.md)]--## 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:-- ```console- git clone https://github.com/Azure-Samples/ms-identity-ciam-dotnet-tutorial.git- ```--- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-ciam-dotnet-tutorial/archive/refs/heads/main.zip). 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.-1. 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](../external-id/customers/how-to-create-external-tenant-portal.md#get-the-external-tenant-details).--You need to host your web API for the iOS sample app to call it. Follow [Quickstart: Deploy an ASP.NET web app](/azure/app-service/quickstart-dotnetcore) to deploy your web API.--## Configure sample iOS 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 Xcode, open `/NativeAuthSampleApp/ProtectedAPIViewController.swift` file. If you're using macOS, here's a sample [ProtectedAPIViewController.swift](https://github.com/Azure-Samples/ms-identity-ciam-native-auth-ios-sample/blob/main/NativeAuthSampleApp/ProtectedAPIViewController.swift) code file.-1. Find `protectedAPIUrl1` and enter your web API URL as its value.-- ```swift- let protectedAPIUrl1: String? = nil // Developers should set the respective URL of their web API here. For example let protectedAPIUrl1: String? = "https://api.example.com/v1/resource"- ```- -1. Find `protectedAPIScopes1` and set the scopes recorded in [Grant API permissions to the iOS sample app](#grant-api-permissions-to-the-ios-sample-app).-- ```swift- let protectedAPIScopes1: [String] = [] // Developers should set the respective scopes of their web API here.For example, let protectedAPIScopes = ["api://{clientId}/{ToDoList.Read}","api://{clientId}/{ToDoList.ReadWrite}"]- ```- -## Run iOS sample app and call web API - -To build and run your app, follow these steps:- -1. To build and run your code, select **Run** from the **Product** menu in Xcode. After a successful build, Xcode will launch the sample app in the Simulator. -1. 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 iOS app for native authentication](../external-id/customers/tutorial-native-authentication-prepare-ios-app.md). 