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
Copy file name to clipboardExpand all lines: V3_MIGRATION_GUIDE.md
+2-141Lines changed: 2 additions & 141 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# v3 Migration Guide
2
2
3
-
> **Note:** This guide is actively maintained during the v3 development phase. As new changes are merged, this document will be updated to reflect the latest breaking changes and migration steps.
4
-
5
3
Auth0.swift v3 includes many significant changes:
6
4
7
5
-**Swift 6 concurrency:** Full strict concurrency compliance with `Sendable` conformances, `@MainActor` callbacks, and `@Sendable` closures across all public APIs.
@@ -186,26 +184,6 @@ final class MyLogger: Logger, @unchecked Sendable {
186
184
187
185
Since custom providers always present UI, they should already be doing UI work on the main thread. In most cases no code changes are required — Swift infers `@Sendable @MainActor` from the `WebAuthProvider` typealias automatically.
188
186
189
-
<details>
190
-
<summary>Migration example</summary>
191
-
192
-
```swift
193
-
// v2
194
-
let myProvider: WebAuthProvider = { url, callback in
195
-
let agent =MyUserAgent(url: url, callback: callback)
196
-
return agent
197
-
}
198
-
199
-
// v3 - Swift infers @Sendable @MainActor from the WebAuthProvider typealias.
200
-
// The closure body runs on the main actor, so MyUserAgent.init is called there.
201
-
// MyUserAgent does not need to be @MainActor, but it must conform to Sendable.
202
-
let myProvider: WebAuthProvider = { url, callback in
203
-
let agent =MyUserAgent(url: url, callback: callback)
204
-
return agent
205
-
}
206
-
```
207
-
</details>
208
-
209
187
### @MainActor callback parameters
210
188
211
189
**Change:** All public callback parameters are now `@MainActor`. This affects the following APIs:
-**Custom `WebAuth` conformances (mocks, test doubles)** — Add `@MainActor` to your `start()` and `logout(federated:)` implementations to match the updated protocol requirement.
-**Callers using `any WebAuth` (protocol existential)** — The `@MainActor` constraint is now enforced at the call site through the protocol. Under strict concurrency, Swift will emit a warning if you call these methods from a non-isolated context without `await`.
286
246
287
247
---
@@ -686,10 +646,8 @@ credentialsManager.credentials { result in
686
646
switch error {
687
647
case .dpopNotConfigured:
688
648
// Developer forgot to call useDPoP() on the Authentication client
689
-
// passed to the credentials manager. Fix the client configuration.
// DPoP key was lost. Clear local state and prompt user to re-authenticate
695
653
case .dpopKeyMismatch:
@@ -905,27 +863,6 @@ Auth0.swift will use a current key window to present the in-app browser for Web
905
863
-`presentationWindow(_ window:)`
906
864
-`useCredentialsManager(_ credentialsManager:)` — Use a `CredentialsManager` instance for automatic credential storage and clearing.
907
865
908
-
<details>
909
-
<summary>Code</summary>
910
-
911
-
```swift
912
-
Auth0
913
-
.webAuth()
914
-
.presentationWindow(window)
915
-
.start { result in
916
-
// ...
917
-
}
918
-
919
-
// Use a CredentialsManager for automatic credential storage
920
-
Auth0
921
-
.webAuth()
922
-
.useCredentialsManager(credentialsManager)
923
-
.start { result in
924
-
// ...
925
-
}
926
-
```
927
-
</details>
928
-
929
866
### Credentials Manager clearAll
930
867
931
868
**New method:**`clearAll() throws` has been added to `CredentialsManager`.
@@ -934,18 +871,6 @@ This method removes **all** entries managed by the Credentials Manager from the
934
871
935
872
This is different from the existing `clear()` method, which only removes the default credentials entry.
936
873
937
-
<details>
938
-
<summary>Code</summary>
939
-
940
-
```swift
941
-
// Clear only the default credentials entry (existing method)
942
-
try credentialsManager.clear()
943
-
944
-
// Clear ALL keychain entries managed by the Credentials Manager (new method)
945
-
try credentialsManager.clearAll()
946
-
```
947
-
</details>
948
-
949
874
**Impact:** This is a new additive API. No migration is required. Use it when you need to completely wipe all stored credentials (e.g., on account deletion or full sign-out).
950
875
951
876
### CredentialsStorage deleteAllEntries
@@ -1020,80 +945,18 @@ The following APIs have been renamed to align with the Android, Flutter, and Rea
1020
945
1021
946
The `clearSession(federated:)` method on the Web Auth client has been renamed to `logout(federated:)`. This affects all three API flavors: callback-based, Combine, and async/await.
1022
947
1023
-
<details>
1024
-
<summary>Migration example</summary>
1025
-
1026
-
```swift
1027
-
// v2
1028
-
Auth0
1029
-
.webAuth()
1030
-
.clearSession { result in
1031
-
// ...
1032
-
}
1033
-
1034
-
tryawait Auth0.webAuth().clearSession()
1035
-
1036
-
// v3
1037
-
Auth0
1038
-
.webAuth()
1039
-
.logout { result in
1040
-
// ...
1041
-
}
1042
-
1043
-
tryawait Auth0.webAuth().logout()
1044
-
```
1045
-
</details>
1046
-
1047
948
**`UserInfo` → `UserProfile`**
1048
949
1049
950
The `UserInfo` struct has been renamed to `UserProfile`. The `userInfo(withAccessToken:)` method name on the Authentication client is unchanged, as it maps to the OIDC `/userinfo` endpoint.
1050
951
1051
-
<details>
1052
-
<summary>Migration example</summary>
1053
-
1054
-
```swift
1055
-
// v2
1056
-
let user: UserInfo =...
1057
-
1058
-
// v3
1059
-
let user: UserProfile =...
1060
-
```
1061
-
</details>
1062
-
1063
952
**`expiresIn` → `expiresAt`**
1064
953
1065
954
The `expiresIn` property on `Credentials`, `APICredentials`, and `SSOCredentials` has been renamed to `expiresAt`. The JSON key (`expires_in`) and Keychain storage key are unchanged.
1066
955
1067
-
<details>
1068
-
<summary>Migration example</summary>
1069
-
1070
-
```swift
1071
-
// v2
1072
-
let expiry = credentials.expiresIn
1073
-
1074
-
// v3
1075
-
let expiry = credentials.expiresAt
1076
-
```
1077
-
</details>
1078
-
1079
956
**`Telemetry` → `Auth0ClientInfo`**
1080
957
1081
958
The `Telemetry` struct has been renamed to `Auth0ClientInfo`, and the `telemetry` property on `Trackable` conforming types has been renamed to `auth0ClientInfo`.
1082
959
1083
-
<details>
1084
-
<summary>Migration example</summary>
1085
-
1086
-
```swift
1087
-
// v2
1088
-
var auth = Auth0.authentication()
1089
-
auth.telemetry.enabled=false
1090
-
1091
-
// v3
1092
-
var auth = Auth0.authentication()
1093
-
auth.auth0ClientInfo.enabled=false
1094
-
```
1095
-
</details>
1096
-
1097
960
### Request to Requestable
1098
961
1099
962
**Change:** All `Authentication` and `MFAClient` methods now return protocol types instead of the concrete `Request` struct:
@@ -1240,7 +1103,5 @@ For example, if you were reading or updating user metadata:
1240
1103
2.**Call that endpoint from your app**, passing the user's access token as a `Bearer` token in the `Authorization` header.
1241
1104
3.**On your backend**, obtain a machine-to-machine token via the [Client Credentials flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) and use it to call the [Management API](https://auth0.com/docs/api/management/v2) with the precise scopes required.
1242
1105
1243
-
**Reason:** The Management API is not designed for direct use from mobile apps — it is heavily restricted for public clients (only a small subset of operations are permitted, and sensitive actions such as managing roles, rules, or other users are not available). It also requires its own audience (`https://YOUR_AUTH0_DOMAIN/api/v2/`), and each individual access token is scoped to a single audience. If your app also needs to call your own backend API, you must set that API's identifier as the audience at login, which means the same token cannot be used for the Management API.
0 commit comments