Added an API key token provider.

This commit is contained in:
javier committed 2026-10-25 18:11:51 +01:00
1 parent a303150963
commit 35b3b7953d
6 files changed
+355 -14

No files matched your search

+12 -6
View File
@@ -46,11 +46,17 @@ let client = Client(
)
```
Tokens expire after 20 minutes at most. For longer-lived clients, pass a token provider instead, which is called on every request:
Tokens expire after 20 minutes at most. For longer-lived clients, use `APIKeyTokenProvider`, which signs new ones with your API key as needed:
```swift
let tokenProvider = try APIKeyTokenProvider(
issuerID: yourIssuerID,
keyID: yourKeyID,
privateKey: yourP8FileContents
)
BearerAuthMiddleware {
try await tokenStore.validToken()
try await tokenProvider.token()
}
```
@@ -82,11 +88,11 @@ repeat {
## Supported Platforms
- iOS 13.0+
- macOS 10.15+
- tvOS 13.0+
- iOS 14.0+
- macOS 11.0+
- tvOS 14.0+
- visionOS 1.0+
- watchOS 6.0+
- watchOS 7.0+
## Development