Your API may require dynamic authentication where credentials need to be generated or refreshed for each request, such as signing short-lived JWTs or rotating tokens. Python SDKs support this pattern through method overrides.
For Python SDKs, you can implement dynamic authentication by extending the generated client and overriding methods to inject authentication logic.
Here’s how to implement JWT signing for Python SDKs:
Create a custom client class that extends the generated Fern client and adds JWT signing logic:
This approach requires overriding each method individually. You’ll need to override all methods that make API calls to ensure JWT authentication is applied consistently across your SDK.
This same pattern works for other dynamic authentication scenarios:
Authorization header. Consider using a different header name or conditionally setting the headerrequest_options as a keyword argument that can include custom headersiat and exp claims to match JWT standards