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
description: Learn about the differences between the Microsoft Authentication Library for ObjectiveC (MSAL for iOS and macOS) and Azure AD Authentication Library for ObjectiveC (ADAL.ObjC) and how to migrate between them.
3
+
description: Learn about the differences between the Microsoft Authentication Library for Objective-C (MSAL for iOS and macOS) and Azure AD Authentication Library for Objective-C (ADAL.ObjC) and how to migrate between them.
4
4
services: active-directory
5
5
author: henrymbuguakiarie
6
6
manager: CelesteDG
@@ -9,73 +9,73 @@ ms.service: active-directory
9
9
ms.subservice: develop
10
10
ms.topic: how-to
11
11
ms.workload: identity
12
-
ms.date: 08/28/2019
12
+
ms.date: 01/18/2023
13
13
ms.author: henrymbugua
14
14
ms.reviewer: jak
15
15
ms.custom: aaddev, has-adal-ref
16
16
#Customer intent: As an application developer, I want to learn about how to use redirect URIs.
17
17
---
18
18
19
-
# Using redirect URIs with the Microsoft authentication library for iOS and macOS
19
+
# Using redirect URIs with the Microsoft Authentication Library (MSAL) for iOS and macOS
20
20
21
21
When a user authenticates, Azure Active Directory (Azure AD) sends the token to the app by using the redirect URI registered with the Azure AD application.
22
22
23
-
The Microsoft Authentication library (MSAL) requires that the redirect URI be registered with the Azure AD app in a specific format. MSAL uses a default redirect URI, if you don't specify one. The format is `msauth.[Your_Bundle_Id]://auth`.
23
+
The MSAL requires that the redirect URI be registered with the Azure AD app in a specific format. MSAL uses a default redirect URI, if you don't specify one. The format is `msauth.[Your_Bundle_Id]://auth`.
24
24
25
25
The default redirect URI format works for most apps and scenarios, including brokered authentication and system web view. Use the default format whenever possible.
26
26
27
-
However, you may need to change the redirect URI for advanced scenarios, as described below.
27
+
However, you may need to change the redirect URI for advanced scenarios, as described in the following section.
28
28
29
29
## Scenarios that require a different redirect URI
30
30
31
-
### Cross-app single signon (SSO)
31
+
### Cross-app single sign-on (SSO)
32
32
33
-
For the Microsoft Identity platform to share tokens across apps, each app needs to have the same client ID or application ID. This is the unique identifier provided when you registered your app in the portal (not the application bundle ID that you register per app with Apple).
33
+
For the Microsoft identity platform to share tokens across apps, each app needs to have the same client ID or application ID. The client ID is the unique identifier provided when you registered your app in the Azure portal (not the application bundle ID that you register per app with Apple).
34
34
35
35
The redirect URIs need to be different for each iOS app. This allows the Microsoft identity service to uniquely identify different apps that share an application ID. Each application can have multiple redirect URIs registered in the Azure portal. Each app in your suite will have a different redirect URI. For example:
36
36
37
37
Given the following application registration in the Azure portal:
38
38
39
-
* Client ID: `ABCDE-12345` (this is a single client ID)
When migrating code that used the Azure AD Authentication Library (ADAL) to MSAL, you may already have a redirect URI configured for your app. You can continue using the same redirect URI as long as your ADAL app was configured to support brokered scenarios and your redirect URI satisfies the MSAL redirect URI format requirements.
48
+
When migrating code that used the Azure Active Directory Authentication Library (ADAL) to MSAL, you may already have a redirect URI configured for your app. You can continue using the same redirect URI as long as your ADAL app was configured to support brokered scenarios and your redirect URI satisfies the MSAL redirect URI format requirements.
49
49
50
50
## MSAL redirect URI format requirements
51
51
52
-
* The MSAL redirect URI must be in the form `<scheme>://host`
52
+
- The MSAL redirect URI must be in the form `<scheme>://host`
53
53
54
-
Where `<scheme>` is a unique string that identifies your app. It's primarily based on the Bundle Identifier of your application to guarantee uniqueness. For example, if your app's Bundle ID is `com.contoso.myapp`, your redirect URI would be in the form: `msauth.com.contoso.myapp://auth`.
54
+
Where `<scheme>` is a unique string that identifies your app. It's primarily based on the Bundle Identifier of your application to guarantee uniqueness. For example, if your app's Bundle ID is `com.contoso.myapp`, your redirect URI would be in the form: `msauth.com.contoso.myapp://auth`.
55
55
56
-
If you're migrating from ADAL, your redirect URI will likely have this format: `<scheme>://[Your_Bundle_Id]`, where `scheme` is a unique string. This format will continue to work when you use MSAL.
56
+
If you're migrating from ADAL, your redirect URI will likely have this format: `<scheme>://[Your_Bundle_Id]`, where `scheme` is a unique string. The format will continue to work when you use MSAL.
57
57
58
-
*`<scheme>` must be registered in your app's Info.plist under `CFBundleURLTypes > CFBundleURLSchemes`. In this example, Info.plist has been opened as source code:
58
+
-`<scheme>` must be registered in your app's Info.plist under `CFBundleURLTypes > CFBundleURLSchemes`. In this example, Info.plist has been opened as source code:
59
59
60
-
```xml
61
-
<key>CFBundleURLTypes</key>
62
-
<array>
63
-
<dict>
64
-
<key>CFBundleURLSchemes</key>
65
-
<array>
66
-
<string>msauth.[BUNDLE_ID]</string>
67
-
</array>
68
-
</dict>
69
-
</array>
70
-
```
60
+
```xml
61
+
<key>CFBundleURLTypes</key>
62
+
<array>
63
+
<dict>
64
+
<key>CFBundleURLSchemes</key>
65
+
<array>
66
+
<string>msauth.[BUNDLE_ID]</string>
67
+
</array>
68
+
</dict>
69
+
</array>
70
+
```
71
71
72
72
MSAL will verify if your redirect URI registers correctly, and return an error if it's not.
73
-
74
-
* If you want to use universal links as a redirect URI, the `<scheme>` must be `https` and doesn't need to be declared in `CFBundleURLSchemes`. Instead, configure the app and domain per Apple's instructions at [Universal Links for Developers](https://developer.apple.com/ios/universal-links/) and call the `handleMSALResponse:sourceApplication:` method of `MSALPublicClientApplication` when your application is opened through a universal link.
73
+
74
+
- If you want to use universal links as a redirect URI, the `<scheme>` must be `https` and doesn't need to be declared in `CFBundleURLSchemes`. Instead, configure the app and domain per Apple's instructions at [Universal Links for Developers](https://developer.apple.com/ios/universal-links/) and call the `handleMSALResponse:sourceApplication:` method of `MSALPublicClientApplication` when your application is opened through a universal link.
75
75
76
76
## Use a custom redirect URI
77
77
78
-
To use a custom redirect URI, pass the `redirectUri` parameter to `MSALPublicClientApplicationConfig` and pass that object to `MSALPublicClientApplication` when you initialize the object. If the redirect URI is invalid, the initializer will return `nil` and set the `redirectURIError`with additional information. For example:
78
+
To use a custom redirect URI, pass the `redirectUri` parameter to `MSALPublicClientApplicationConfig` and pass that object to `MSALPublicClientApplication` when you initialize the object. If the redirect URI is invalid, the initializer will return `nil` and set the `redirectURIError`with additional information. For example:
79
79
80
80
Objective-C:
81
81
@@ -97,14 +97,12 @@ let config = MSALPublicClientApplicationConfig(clientId: "your-client-id",
97
97
authority: authority)
98
98
do {
99
99
let application = try MSALPublicClientApplication(configuration: config)
100
-
// continue on with application
100
+
// continue on with application
101
101
} catch let error as NSError {
102
102
// handle error here
103
-
}
103
+
}
104
104
```
105
105
106
-
107
-
108
106
## Handle the URL opened event
109
107
110
108
Your application should call MSAL when it receives any response through URL schemes or universal links. Call the `handleMSALResponse:sourceApplication:` method of `MSALPublicClientApplication` when your application is opened. Here's an example for custom schemes:
0 commit comments