Security callbacks
Instead of providing credentials once during SDK instantiation, you can pass a custom authentication function that allows end users to manage secrets dynamically. Custom authentication functions 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: httpscheme: 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 hereconst token = "<YOUR_JWT>";return { bearerAuth: token };},});