Skip to content

Commit e354332

Browse files
update docs
1 parent 5ddf802 commit e354332

File tree

2 files changed

+100
-8
lines changed

2 files changed

+100
-8
lines changed

EXAMPLES.md

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,28 @@ The Credentials Manager utility allows you to securely store and retrieve the us
367367
let credentialsManager = CredentialsManager(authentication: Auth0.authentication())
368368
```
369369

370+
> [!NOTE]
371+
> **Swift 6 Concurrency Support**: The Credentials Manager conforms to `Sendable` and can be safely used across concurrency contexts, including within actors.
372+
>
373+
> ```swift
374+
> // Example: Using CredentialsManager in an Actor (Swift 6)
375+
> actor AuthService {
376+
> let credentialsManager: CredentialsManager
377+
>
378+
> init() {
379+
> self.credentialsManager = CredentialsManager(authentication: Auth0.authentication())
380+
> }
381+
>
382+
> func fetchCredentials() async throws -> Credentials {
383+
> // Safe to call from within an actor
384+
> return try await credentialsManager.credentials(withScope: "openid profile email",
385+
> minTTL: 60,
386+
> parameters: [:],
387+
> headers: [:])
388+
> }
389+
> }
390+
> ```
391+
370392
> [!CAUTION]
371393
> The Credentials Manager is not thread-safe, except for the following methods:
372394
>
@@ -2965,7 +2987,11 @@ Check the [API documentation](https://auth0.github.io/Auth0.swift/documentation/
29652987

29662988
## Logging
29672989

2968-
Auth0.swift can print HTTP requests and responses for debugging purposes. Enable it by calling the following method in either `WebAuth`, `Authentication` or `Users`:
2990+
Auth0.swift provides comprehensive logging capabilities for debugging HTTP requests and responses. The logging system is built on Apple's [Unified Logging](https://developer.apple.com/documentation/os/logging) (`OSLog`) for better performance and integration with system diagnostic tools.
2991+
2992+
### Enable Logging
2993+
2994+
Enable logging by calling the `logging(enabled:)` method on `WebAuth`, `Authentication`, or `Users`:
29692995

29702996
```swift
29712997
Auth0
@@ -2974,32 +3000,98 @@ Auth0
29743000
// ...
29753001
```
29763002

3003+
```swift
3004+
Auth0
3005+
.authentication()
3006+
.logging(enabled: true)
3007+
// ...
3008+
```
3009+
3010+
```swift
3011+
Auth0
3012+
.users(token: credentials.accessToken)
3013+
.logging(enabled: true)
3014+
// ...
3015+
```
3016+
29773017
> [!CAUTION]
2978-
> Set this flag only when **DEBUGGING** to avoid leaking user's credentials in the device log.
3018+
> Enable logging **only when debugging** to avoid performance impacts and potential security concerns in production builds.
29793019
2980-
With a successful authentication you should see something similar to the following:
3020+
### Automatic Token Redaction
3021+
3022+
**Security First**: Auth0.swift automatically redacts sensitive information from logs to protect user credentials. The following fields are redacted when logging HTTP responses:
3023+
3024+
- `access_token`
3025+
- `refresh_token`
3026+
- `id_token`
3027+
3028+
Redacted tokens appear as `"redacted"` in the logs, ensuring sensitive data never appears in plain text.
3029+
3030+
### Logging Output
3031+
3032+
With logging enabled, you'll see detailed HTTP request and response information. Here's an example of what a successful authentication flow looks like:
29813033

29823034
```text
29833035
ASWebAuthenticationSession: https://example.us.auth0.com/authorize?.....
29843036
Callback URL: com.example.MyApp://example.us.auth0.com/ios/com.example.MyApp/callback?...
3037+
29853038
POST https://example.us.auth0.com/oauth/token HTTP/1.1
29863039
Content-Type: application/json
29873040
Auth0-Client: eyJ2ZXJzaW9uI...
29883041
2989-
{"code":"...","client_id":"...","grant_type":"authorization_code","redirect_uri":"com.example.MyApp:\/\/example.us.auth0.com\/ios\/com.example.MyApp\/callback","code_verifier":"..."}
3042+
{
3043+
"code": "...",
3044+
"client_id": "...",
3045+
"grant_type": "authorization_code",
3046+
"redirect_uri": "com.example.MyApp://example.us.auth0.com/ios/com.example.MyApp/callback",
3047+
"code_verifier": "..."
3048+
}
29903049
29913050
HTTP/1.1 200
29923051
Pragma: no-cache
29933052
Content-Type: application/json
29943053
Strict-Transport-Security: max-age=3600
2995-
Date: Wed, 27 Apr 2022 19:04:39 GMT
2996-
Content-Length: 57
3054+
Date: Wed, 08 Dec 2025 10:30:00 GMT
3055+
Content-Length: 1024
29973056
Cache-Control: no-cache
29983057
Connection: keep-alive
29993058
3000-
{"access_token":"...","token_type":"Bearer"}
3059+
{
3060+
"access_token": "redacted",
3061+
"refresh_token": "redacted",
3062+
"id_token": "redacted",
3063+
"token_type": "Bearer",
3064+
"expires_in": 86400
3065+
}
30013066
```
30023067

3068+
### Viewing Logs
3069+
3070+
Auth0.swift logs are written to the **Unified Logging System** with the following identifiers:
3071+
3072+
- **Subsystem**: `com.auth0.Auth0`
3073+
- **Categories**: `NetworkTracing`, `Configuration`
3074+
3075+
#### Xcode Console (Recommended)
3076+
3077+
Logs appear automatically in the Xcode debug console during development on all platforms.
3078+
3079+
**Filtering in Xcode 15+:**
3080+
3081+
Use these filter expressions directly in the console search bar:
3082+
3083+
| Filter | Description |
3084+
|--------|-------------|
3085+
| `subsystem:com.auth0.Auth0` | Show all Auth0 SDK logs |
3086+
| `category:NetworkTracing` | Show only network requests/responses |
3087+
| `category:Configuration` | Show only configuration errors |
3088+
| `subsystem:com.auth0.Auth0 category:NetworkTracing` | Combine filters for specific logs |
3089+
3090+
#### Log Categories
3091+
3092+
- **NetworkTracing** - HTTP requests and responses (enabled via `logging(enabled: true)`)
3093+
- **Configuration** - SDK setup and configuration issues (always logged)
3094+
30033095
> [!TIP]
30043096
> When troubleshooting, you can also check the logs in the [Auth0 Dashboard](https://manage.auth0.com/#/logs) for more information.
30053097

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ Check the [FAQ](FAQ.md) for more information about the alert box that pops up **
347347

348348
Auth0.swift uses Apple's Unified Logging (OSLog) to help you troubleshoot issues during development. Enable detailed HTTP logging to see network requests, responses, and errors.
349349

350-
### Enable Logging (NetworK Tracing based logs)
350+
### Enable Logging (Network Tracing based logs)
351351

352352
To enable detailed HTTP request and response tracing during development:
353353

0 commit comments

Comments
 (0)