Skip to content

SDKs

Security callbacks

Instead of providing credentials once during SDK instantiation, 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
TypeScript
Status
Python
Status
Go
Status
C#
Status
Java
Status
PHP
Status
Ruby
Status

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 };
},
});