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. Fern-generated SDKs support this pattern through language-specific approaches.
Each language has its own recommended approach for implementing dynamic authentication:
Use custom fetcher middleware to inject authentication logic in a single place for all requests. Supports JWT signing, OAuth token refresh, and more.
Use method overrides to inject authentication logic for each API call. Supports JWT signing, OAuth token refresh, and more.
Dynamic authentication is useful for several scenarios:
When implementing dynamic authentication, keep these language-agnostic considerations in mind:
iat and exp claims to match standards