Speakeasy Logo
Skip to Content

Custom Security Schemes

Custom Security Schemes define a JSON Schema for SDK security options. Combined with SDK Hooks, custom authentication and authorization schemes can be implemented beyond OpenAPI’s capabilities.

Language support

TypeScript
Python
Go
C#
🏗️
Java

Define a custom security scheme

Define the custom security scheme under components -> securitySchemes and reference it in the security section. Set the type to http and the scheme to custom. Use the x-speakeasy-custom-security-scheme extension to specify a JSON Schema. This schema must include at least one property and can accommodate multiple properties with different schema definitions.

Initialize the custom security scheme

Once the SDK is regenerated, the custom security scheme can be configured globally or per operation, depending on the security definitions.

Use the custom security scheme

Use SDK Hooks to access user-provided security values and enable custom authentication workflows, like adding headers to requests.

The following example illustrates accessing a custom security scheme in a hook and adding headers to a request:

Last updated on