Security Callbacks
Instead of providing credentials once during SDK instantiation, passing a custom authentication function allows end-users to manage secrets dynamically. This can be used to automatically refresh tokens or retrieve secrets from a secret store.
Language Support
Typescript | Python | Go | C# | Java | PHP | Swift | Ruby |
---|---|---|---|---|---|---|---|
✅ | ✅ | ✅ | ✅️ | ✅ | 🏗️ | 🏗️ | 🏗️ |
Example: Bearer Authentication
In this example, Bearer authentication is used as the only security scheme:
security: - bearerAuth: []components: securitySchemes: bearerAuth: type: http scheme: bearer
The callback function passed when initializing the SDK acts as a security source and is called whenever a request is made, allowing tokens to be refreshed if needed.
import { SDK } from "<packageName>";import { Security } from "<packageName>/models";const sdk = new SDK({ security: async (): Promise<Security> => { // refresh token here const token = "<YOUR_JWT>"; return { bearerAuth: token }; },});