Skip to content

Commit d239c76

Browse files
authored
Update the Flutter QS to feature HTTPS redirect URLs on iOS/macOS [SDK-4756] (#10385)
* Update the Flutter QS to include HTTPS redirect URLs on iOS/macOS * Update the `download.md` instructions * Update reference to Xcode UI * Rework a few sentences * Reword sentence in `download.md` * Rephrase custom domain callout
1 parent ae528b7 commit d239c76

File tree

8 files changed

+174
-90
lines changed

8 files changed

+174
-90
lines changed

articles/quickstart/native/flutter/01-login.md

+78-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ github:
2626
Auth0 allows you to quickly add authentication and access user profile information in your app. This guide demonstrates how to integrate Auth0 with a Flutter app using the [Auth0 Flutter SDK](https://github.com/auth0/auth0-flutter).
2727

2828
:::note
29-
The Flutter SDK currently only supports Flutter app running on Android, iOS, and macOS platforms.
29+
The Flutter SDK currently only supports Flutter apps for Android, iOS, and macOS.
3030
:::
3131

3232
## Getting started
@@ -35,7 +35,49 @@ This quickstart assumes you already have a [Flutter](https://flutter.dev/) app u
3535

3636
You should also be familiar with the [Flutter command line tool](https://docs.flutter.dev/reference/flutter-cli).
3737

38-
<%= include('_configure_urls_interactive') %>
38+
Finally, you will need a **Native** Auth0 application. If you don’t have a Native Auth0 application already, [create one](/get-started/auth0-overview/create-applications/native-apps) before continuing. Avoid using other application types, as they have different configurations and may cause errors.
39+
40+
### Configure the callback and logout URLs
41+
42+
The callback and logout URLs are the URLs that Auth0 invokes to redirect back to your app. Auth0 invokes the callback URL after authenticating the user, and the logout URL after removing the session cookie.
43+
44+
If the callback and logout URLs are not set, users will be unable to log in and out of the app and will get an error.
45+
46+
Go to the [settings page](${manage_url}/#/applications/${account.clientId}/settings) of your Auth0 application and add the following URLs to **Allowed Callback URLs** and **Allowed Logout URLs**, depending on the platform of your app. If you have a [custom domain](/customize/custom-domains), use this instead of the Auth0 domain from the settings page.
47+
48+
::: note
49+
On Android, the value of the `SCHEME` placeholder can be `https` or some other custom scheme. `https` schemes require enabling [Android App Links](https://auth0.com/docs/get-started/applications/enable-android-app-links-support).
50+
51+
On iOS 17.4+ and macOS 14.4+ it is possible to use Universal Links (`https` scheme) as callback and logout URLs. When enabled, the SDK will fall back to using a custom URL scheme on older iOS / macOS versions –your app's [bundle identifier](https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids).
52+
**This feature requires Xcode 15.3+ and a paid Apple Developer account**.
53+
:::
54+
55+
#### Android
56+
57+
```text
58+
SCHEME://${account.namespace}/android/YOUR_PACKAGE_NAME/callback
59+
```
60+
61+
#### iOS
62+
63+
```text
64+
https://${account.namespace}/ios/YOUR_BUNDLE_IDENTIFIER/callback,
65+
YOUR_BUNDLE_IDENTIFIER://${account.namespace}/ios/YOUR_BUNDLE_IDENTIFIER/callback
66+
```
67+
68+
#### macOS
69+
70+
```text
71+
https://${account.namespace}/macos/YOUR_BUNDLE_IDENTIFIER/callback,
72+
YOUR_BUNDLE_IDENTIFIER://${account.namespace}/macos/YOUR_BUNDLE_IDENTIFIER/callback
73+
```
74+
75+
For example, if your iOS bundle identifier were `com.example.MyApp` and your Auth0 domain were `example.us.auth0.com`, then this value would be:
76+
77+
```text
78+
https://example.us.auth0.com/ios/com.example.MyApp/callback,
79+
com.example.MyApp://example.us.auth0.com/ios/com.example.MyApp/callback
80+
```
3981

4082
## Install the Auth0 Flutter SDK
4183

@@ -81,13 +123,37 @@ Run **Sync Project with Gradle Files** inside Android Studio to apply your chang
81123

82124
## Configure iOS/macOS
83125

84-
If you are not developing for the iOS or macOS platform, skip this step.
126+
If you are not developing for the iOS or macOS platforms, skip this step.
127+
128+
::: warning
129+
This step requires a paid Apple Developer account. It is needed to use Universal Links as callback and logout URLs. Skip this step to use a custom URL scheme instead.
130+
:::
131+
132+
#### Configure the Team ID and bundle identifier
133+
134+
Go to the [settings page](${manage_url}/#/applications/${account.clientId}/settings) of your Auth0 application, scroll to the end, and open **Advanced Settings > Device Settings**. In the **iOS** section, set **Team ID** to your [Apple Team ID](https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/), and **App ID** to your app's bundle identifier.
135+
136+
<p><img src="/media/articles/native-platforms/ios-swift/ios-device-settings.png" alt="Screenshot of the iOS section inside the Auth0 application settings page"></p>
85137

86-
You need to register your bundle identifier as a custom URL scheme so the callback and logout URLs can reach your app.
138+
This will add your app to your Auth0 tenant's `apple-app-site-association` file.
87139

88-
In Xcode, go to the **Info** tab of your app target settings. In the **URL Types** section, select the **** button to add a new entry. Then enter `auth0` into the **Identifier** field and `$(PRODUCT_BUNDLE_IDENTIFIER)` into the **URL Schemes** field.
140+
#### Add the associated domain capability
89141

90-
<p><img src="/media/articles/native-platforms/ios-swift/url-scheme.png" alt="Custom URL Scheme"></p>
142+
Open your app in Xcode by running `open ios/Runner.xcworkspace` (or `open macos/Runner.xcworkspace` for macOS). Go to the **Signing and Capabilities** [tab](https://developer.apple.com/documentation/xcode/adding-capabilities-to-your-app#Add-a-capability) of the **Runner** target settings, and press the **+ Capability** button. Then select **Associated Domains**.
143+
144+
<p><img src="/media/articles/native-platforms/ios-swift/ios-xcode-capabilities.png" alt="Screenshot of the capabilities library inside Xcode"></p>
145+
146+
Next, add the following [entry](https://developer.apple.com/documentation/xcode/configuring-an-associated-domain#Define-a-service-and-its-associated-domain) under **Associated Domains**:
147+
148+
```text
149+
webcredentials:${account.namespace}
150+
```
151+
152+
If you have a [custom domain](/customize/custom-domains), use this instead of the Auth0 domain from the settings page.
153+
154+
::: note
155+
For the associated domain to work, your app must be signed with your team certificate **even when building for the iOS simulator**. Make sure you are using the Apple Team whose Team ID is configured in the settings page of your Auth0 application.
156+
:::
91157

92158
## Add login to your app
93159

@@ -129,8 +195,10 @@ Next, redirect your users to the Auth0 Universal Login page using `webAuthentica
129195
if (_credentials == null) {
130196
ElevatedButton(
131197
onPressed: () async {
198+
// Use a Universal Link callback URL on iOS 17.4+ / macOS 14.4+
199+
// useHTTPS is ignored on Android
132200
final credentials =
133-
await auth0.webAuthentication().login();
201+
await auth0.webAuthentication().login(useHTTPS: true);
134202
135203
setState(() {
136204
_credentials = credentials;
@@ -177,7 +245,9 @@ See this example of an `ElevatedButton` widget that logs the user out of the app
177245
```dart
178246
ElevatedButton(
179247
onPressed: () async {
180-
await auth0.webAuthentication().logout();
248+
// Use a Universal Link logout URL on iOS 17.4+ / macOS 14.4+
249+
// useHTTPS is ignored on Android
250+
await auth0.webAuthentication().logout(useHTTPS: true);
181251
182252
setState(() {
183253
_credentials = null;

articles/quickstart/native/flutter/_configure_urls_interactive.md

+28-22
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,50 @@
22

33
To use Auth0 services, you need to have an application set up in the Auth0 Dashboard. The Auth0 application is where you will configure how you want authentication to work for your project.
44

5-
:::note
6-
The URLs below make use of a `SCHEME` placeholder, and this value varies depending on what platform you're working with. On Android, this can be `https` or some other custom scheme. On iOS/macOS, this is your app's [bundle identifier](https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids).
7-
:::
8-
95
### Configure an Auth0 application
106

11-
Use the interactive selector to create a new "Native Application", or select an existing application that represents the project you want to integrate with. Every application in Auth0 is assigned an alphanumeric, unique client ID that your application code will use to call Auth0 APIs through the SDK.
7+
Use the interactive selector to create a new Auth0 application or select an existing **Native** Auth0 application. Every application in Auth0 is assigned an alphanumeric, unique client ID that your application code will use to call Auth0 APIs through the SDK.
128

139
Any settings you configure using this quickstart will automatically update for your application in the <a href="${manage_url}/#/">Dashboard</a>, which is where you can manage your applications in the future.
1410

1511
If you would rather explore a complete configuration, you can view a sample app instead.
1612

17-
### Configure Callback URLs
13+
### Configure the callback and logout URLs
1814

19-
A callback URL is a URL in your app that you would like Auth0 to redirect users to after they have authenticated. If not set, users will not be returned to your app after they log in.
20-
21-
::: note
22-
If you are following along with our sample project, set this to one of the following URLs, depending on your platform:
15+
The callback and logout URLs are the URLs that Auth0 invokes to redirect back to your app. Auth0 invokes the callback URL after authenticating the user, and the logout URL after removing the session cookie. If the callback and logout URLs are not set, users will be unable to log in and out of the app and will get an error.
2316

24-
**Android**: `SCHEME://${account.namespace}/android/YOUR_PACKAGE_NAME/callback`
17+
Set the callback and logout URLs to the following values, depending on your platform.
2518

26-
**iOS**: `YOUR_BUNDLE_ID://${account.namespace}/ios/YOUR_BUNDLE_ID/callback`
19+
::: note
20+
On Android, the value of the `SCHEME` placeholder can be `https` or some other custom scheme. `https` schemes require enabling [Android App Links](https://auth0.com/docs/get-started/applications/enable-android-app-links-support).
2721

28-
**macOS**: `YOUR_BUNDLE_ID://${account.namespace}/macos/YOUR_BUNDLE_ID/callback`
22+
On iOS 17.4+ and macOS 14.4+ it is possible to use Universal Links (`https` scheme) as callback and logout URLs. When enabled, the SDK will fall back to using a custom URL scheme on older iOS / macOS versions –your app's [bundle identifier](https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids).
23+
**This feature requires Xcode 15.3+ and a paid Apple Developer account**.
2924
:::
3025

31-
### Configure Logout URLs
26+
#### Android
3227

33-
A logout URL is a URL in your app that you would like Auth0 to redirect users to after they have logged out. If not set, users will not be able to log out from your app and will receive an error.
28+
```text
29+
SCHEME://${account.namespace}/android/YOUR_PACKAGE_NAME/callback
30+
```
3431

35-
::: note
36-
If you are following along with our sample project, set this to one of the following URLs, depending on your platform:
32+
#### iOS
3733

38-
**Android**: `SCHEME://${account.namespace}/android/YOUR_PACKAGE_NAME/callback`
34+
```text
35+
https://${account.namespace}/ios/YOUR_BUNDLE_IDENTIFIER/callback,
36+
YOUR_BUNDLE_IDENTIFIER://${account.namespace}/ios/YOUR_BUNDLE_IDENTIFIER/callback
37+
```
3938

40-
**iOS**: `YOUR_BUNDLE_ID://${account.namespace}/ios/YOUR_BUNDLE_ID/callback`
39+
#### macOS
4140

42-
**macOS**: `YOUR_BUNDLE_ID://${account.namespace}/macos/YOUR_BUNDLE_ID/callback`
43-
:::
41+
```text
42+
https://${account.namespace}/macos/YOUR_BUNDLE_IDENTIFIER/callback,
43+
YOUR_BUNDLE_IDENTIFIER://${account.namespace}/macos/YOUR_BUNDLE_IDENTIFIER/callback
44+
```
45+
46+
For example, if your iOS bundle identifier were `com.example.MyApp` and your Auth0 domain were `example.us.auth0.com`, then this value would be:
4447

45-
Lastly, be sure that the **Application Type** for your application is set to **Native** in the [Application Settings](${manage_url}/#/applications/${account.clientId}/settings).
48+
```text
49+
https://example.us.auth0.com/ios/com.example.MyApp/callback,
50+
com.example.MyApp://example.us.auth0.com/ios/com.example.MyApp/callback
51+
```
+17-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
To run the sample follow these steps:
1+
<!-- markdownlint-disable MD041 -->
22

3-
1) Set the **Allowed Callback URLs** and **Allowed Logout URLs** in the [Application Settings](${manage_url}/#/applications/${account.clientId}/settings) to the following value so it works for Android, iOS, and macOS apps:
3+
> On every step, if you have a [custom domain](https://auth0.com/docs/customize/custom-domains), replace the `YOUR_AUTH0_DOMAIN` placeholder with your custom domain instead of the value from the settings page.
44
5-
```text
6-
com.auth0.samples.FlutterSample://${account.namespace}/ios/com.auth0.samples.FlutterSample/callback,com.auth0.sample://${account.namespace}/android/com.auth0.sample/callback,com.auth0.sample://${account.namespace}/macos/com.auth0.sample/callback
7-
```
5+
## 1. Configure the Auth0 application
86

9-
2) Rename the file `.env.example` to `.env` and fill in the following values:
7+
Open the settings page of your Auth0 application and add the following URLs to **Allowed Callback URLs** and **Allowed Logout URLs**, depending on the platform you want to use.
108

11-
```sh
12-
AUTH0_DOMAIN=${account.namespace}
13-
AUTH0_CLIENT_ID=${account.clientId}
14-
AUTH0_CUSTOM_SCHEME=com.auth0.sample
15-
```
9+
- Android: `com.auth0.sample://YOUR_AUTH0_DOMAIN/android/com.auth0.sample/callback`
10+
- iOS: `https://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_IDENTIFIER/callback,YOUR_BUNDLE_IDENTIFIER://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_IDENTIFIER/callback`
11+
- macOS: `https://YOUR_AUTH0_DOMAIN/macos/YOUR_BUNDLE_IDENTIFIER/callback,YOUR_BUNDLE_IDENTIFIER://YOUR_AUTH0_DOMAIN/macos/YOUR_BUNDLE_IDENTIFIER/callback`
1612

17-
3) Rename the file `strings.xml.example` in `android/app/src/main/res/values` to `strings.xml` and fill in the following values:
13+
## 2. Configure the associated domain (iOS/macOS only)
1814

19-
```xml
20-
<?xml version="1.0" encoding="utf-8"?>
21-
<resources>
22-
<string name="com_auth0_domain">${account.namespace}</string>
23-
<string name="com_auth0_scheme">com.auth0.sample</string>
24-
</resources>
25-
```
15+
> **This following requires Xcode 15.3+ and a paid Apple Developer account**. If you do not have a paid Apple Developer account, skip this step, and set the `useHTTPS` parameter to `false` in the `login()` and `logout()` calls at `lib/example_app.dart`.
2616
27-
4) Use the [Flutter CLI's](https://docs.flutter.dev/reference/flutter-cli) `run` command to run the app:
17+
Open `ios/Runner.xcodeproj` (or `macos/Runner.xcodeproj`, for macOS) in Xcode and go to the settings of the **Runner** app target. In the **Signing & Capabilities** tab, change the bundle identifier from the default `com.auth0.samples.FlutterSample` to another value of your choosing. Then, make sure the **Automatically manage signing** box is checked, and that your Apple Team is selected.
2818

29-
```sh
30-
flutter run
31-
```
19+
Next, find the `webcredentials:YOUR_AUTH0_DOMAIN` entry under **Associated Domains**, and replace the `YOUR_AUTH0_DOMAIN` placeholder with the domain of your Auth0 application.
20+
21+
Finally, open the settings page of your Auth0 application, scroll to the end, and open **Advanced Settings > Device Settings**. In the **iOS** section, set **Team ID** to your [Apple Team ID](https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/), and **App ID** to the app's bundle identifier.
22+
23+
## 3. Run the app
24+
25+
Use the [Flutter CLI](https://docs.flutter.dev/reference/flutter-cli) to run the app: `flutter run`.

articles/quickstart/native/flutter/files/main.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ class _MainViewState extends State<MainView> {
3434
if (_credentials == null)
3535
ElevatedButton(
3636
onPressed: () async {
37+
// Use a Universal Link callback URL on iOS 17.4+ / macOS 14.4+
38+
// useHTTPS is ignored on Android
3739
final credentials =
38-
await auth0.webAuthentication().login();
40+
await auth0.webAuthentication().login(useHTTPS: true);
3941
4042
setState(() {
4143
_credentials = credentials;
@@ -48,7 +50,9 @@ class _MainViewState extends State<MainView> {
4850
ProfileView(user: _credentials!.user),
4951
ElevatedButton(
5052
onPressed: () async {
51-
await auth0.webAuthentication().logout();
53+
// Use a Universal Link logout URL on iOS 17.4+ / macOS 14.4+
54+
// useHTTPS is ignored on Android
55+
await auth0.webAuthentication().logout(useHTTPS: true);
5256
5357
setState(() {
5458
_credentials = null;

0 commit comments

Comments
 (0)