Added an API key token provider.
This commit is contained in:
1 parent
a303150963
commit
35b3b7953d
6 files changed
+355
-14
No files matched your search
@@ -23,11 +23,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()
|
||||
}
|
||||
```
|
||||
|
||||
@@ -67,6 +73,7 @@ repeat {
|
||||
### Authentication
|
||||
|
||||
- ``BearerAuthMiddleware``
|
||||
- ``APIKeyTokenProvider``
|
||||
|
||||
### Generated Types
|
||||
|
||||
|
||||
Reference in new issue
Block a user