Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main/docs/libraries/auth0-android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In your app's `build.gradle` dependencies section, add the following:
```kotlin lines
dependencies {
// Add the Auth0 Android SDK
implementation 'com.auth0.android:auth0:2.+'
implementation 'com.auth0.android:auth0:4.0.0'
}
```

Expand Down
32 changes: 12 additions & 20 deletions main/docs/libraries/auth0-swift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ title: Auth0.swift
---
<Card title="Overview">

Swift SDK for iOS, macOS, tvOS, and watchOS that enables you to seamlessly integrate Auth0 into your apps. Add login and logout, store credentials securely, and access user information.
Swift SDK for iOS, macOS, tvOS, watchOS, and visionOS that enables you to seamlessly integrate Auth0 into your apps. Add login and logout, store credentials securely, and access user information.

**See the** [**GitHub repository**](https://github.com/auth0/Auth0.swift)

**Migrating from v1? Check the** [**Migration Guide**](https://github.com/auth0/Auth0.swift/blob/master/V2_MIGRATION_GUIDE.md)
**Migrating from v2? Check the** [**Migration Guide**](https://github.com/auth0/Auth0.swift/blob/master/V3_MIGRATION_GUIDE.md)

</Card>

Expand All @@ -22,17 +22,17 @@ Swift SDK for iOS, macOS, tvOS, and watchOS that enables you to seamlessly integ
+ [Web Auth](https://auth0.github.io/Auth0.swift/documentation/auth0/webauth)
+ [Credentials Manager](https://auth0.github.io/Auth0.swift/documentation/auth0/credentialsmanager)
+ [Authentication API Client](https://auth0.github.io/Auth0.swift/documentation/auth0/authentication)
+ [Management API Client (Users)](https://auth0.github.io/Auth0.swift/documentation/auth0/users)
+ [MFA API Client](https://auth0.github.io/Auth0.swift/documentation/auth0/mfaclient)
* [FAQ](https://github.com/auth0/Auth0.swift/blob/master/FAQ.md): Answers some common questions about Auth0.swift.
* [Auth0 Documentation:](https://auth0.com/docs) Explore our docs site and learn more about Auth0.

## Getting started

### Requirements

* iOS 13.0+ / macOS 11.0+ / tvOS 13.0+ / watchOS 7.0+
* Xcode 14.x
* Swift 5.7+
* iOS 14.0+ / macOS 11.0+ / tvOS 14.0+ / watchOS 7.0+ / visionOS 1.0+
* Xcode 16.x
* Swift 6.0+

<Warning>

Expand Down Expand Up @@ -61,7 +61,7 @@ Then, select the dependency rule and press **Add Package**.
Add the following line to your `Podfile`:

```bash lines
pod 'Auth0', '~> 2.0'
pod 'Auth0', '~> 3.0'
```

Then, run `pod install`.
Expand All @@ -71,7 +71,7 @@ Then, run `pod install`.
Add the following line to your `Cartfile`:

```bash lines
github "auth0/Auth0.swift" ~> 2.0
github "auth0/Auth0.swift" ~> 3.0
```

Then, run `carthage bootstrap --use-xcframeworks`.
Expand Down Expand Up @@ -117,14 +117,6 @@ Auth0
// ...
```

##### For the Management API client (Users)

```swift lines
Auth0
.users(token: credentials.accessToken, domain: "{yourAuth0Domain}")
// ...
```

### Configure Web Auth (iOS / macOS)

#### Configure callback URL and logout URL
Expand Down Expand Up @@ -219,12 +211,12 @@ Auth0

Logging the user out involves clearing the <Tooltip tip="Universal Login: Your application redirects to Universal Login, hosted on Auth0's Authorization Server, to verify a user's identity." cta="View Glossary" href="/docs/glossary?term=Universal+Login">Universal Login</Tooltip> session cookie and then deleting the user's credentials from your application.

Call the `clearSession()` method in the action of your **Logout** button. Once the session cookie has been cleared, [delete the user's credentials](https://github.com/auth0/Auth0.swift/blob/master/EXAMPLES.md#clear-stored-credentials).
Call the `logout()` method in the action of your **Logout** button. Once the session cookie has been cleared, [delete the user's credentials](https://github.com/auth0/Auth0.swift/blob/master/EXAMPLES.md#clear-stored-credentials).

```swift lines
Auth0
.webAuth()
.clearSession { result in
.logout { result in
switch result {
case .success:
print("Session cookie cleared")
Expand All @@ -239,7 +231,7 @@ Auth0

```swift lines
do {
try await Auth0.webAuth().clearSession()
try await Auth0.webAuth().logout()
print("Session cookie cleared")
// Delete credentials
} catch {
Expand All @@ -252,7 +244,7 @@ do {
```swift lines
Auth0
.webAuth()
.clearSession()
.logout()
.sink(receiveCompletion: { completion in
switch completion {
case .finished:
Expand Down
26 changes: 14 additions & 12 deletions main/docs/quickstart/native/ios-swift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Your AI assistant will automatically create your Auth0 application, fetch creden
@MainActor
class AuthenticationService: ObservableObject {
@Published var isAuthenticated = false
@Published var user: User?
@Published var user: UserProfile?
@Published var isLoading = false
@Published var errorMessage: String?

Expand All @@ -203,8 +203,8 @@ Your AI assistant will automatically create your Auth0 application, fetch creden
}

isAuthenticated = true
// Get user info from the ID token
user = credentials.user
// Get the user profile from the stored ID token
user = try? credentialsManager.userProfile()
}

func login() async {
Expand All @@ -213,15 +213,16 @@ Your AI assistant will automatically create your Auth0 application, fetch creden
defer { isLoading = false }

do {
let credentials = try await Auth0
// offline_access is included in the default scope as of v3, shown here for clarity
_ = try await Auth0
.webAuth()
.scope("openid profile email offline_access")
.useCredentialsManager(credentialsManager)
.start()

_ = credentialsManager.store(credentials: credentials)
isAuthenticated = true
// Get user info from the ID token
user = credentials.user
// Get the user profile from the stored ID token
user = try? credentialsManager.userProfile()
} catch {
errorMessage = "Login failed: \(error.localizedDescription)"
}
Expand All @@ -234,8 +235,8 @@ Your AI assistant will automatically create your Auth0 application, fetch creden
do {
try await Auth0
.webAuth()
.clearSession()
_ = credentialsManager.clear()
.useCredentialsManager(credentialsManager)
.logout()
isAuthenticated = false
user = nil
} catch {
Expand Down Expand Up @@ -277,12 +278,13 @@ Your AI assistant will automatically create your Auth0 application, fetch creden
let credentials = try await Auth0
.webAuth()
.scope("openid profile email offline_access")
.useCredentialsManager(credentialsManager)
.useEphemeralSession()
.start()
```

<Info>
When using ephemeral sessions, you don't need to call `clearSession()` on logout. Just clear the credentials from your app - there's no shared cookie to remove.
When using ephemeral sessions, you don't need to call `logout()` on the Web Auth client. Just clear the credentials from your app - there's no shared cookie to remove.
</Info>

<Tip>
Expand Down Expand Up @@ -376,7 +378,7 @@ Require Face ID or Touch ID to access stored credentials:

```swift
private let credentialsManager: CredentialsManager = {
let manager = CredentialsManager(authentication: Auth0.authentication())
var manager = CredentialsManager(authentication: Auth0.authentication())
manager.enableBiometrics(
withTitle: "Unlock with Face ID",
cancelTitle: "Cancel",
Expand Down Expand Up @@ -409,7 +411,7 @@ For widgets, app extensions, or background tasks that need access tokens:
let credentialsManager = CredentialsManager(
authentication: Auth0.authentication(),
storeKey: "credentials",
storage: .shared(withIdentifier: "group.com.example.myapp")
storage: SimpleKeychain(accessGroup: "group.com.example.myapp")
)
```

Expand Down
Loading