Authentication
Model auth schemes such as bearer, basic, and api key for your event-driven APIs.
Configuring authentication schemes happens in the components.securitySchemes
section of AsyncAPI.
To apply a security scheme across all operations, reference the securityScheme
within the security
section of your AsyncAPI Specification.
Bearer security scheme
Start by defining a bearer
security scheme in your asyncapi.yml
:
This will generate an SDK where the user would have to provide
a mandatory argument called token
.
If you want to control variable naming and the environment variable to scan, use the configuration below:
API Key security scheme
Start by defining an apiKey
security scheme in your asyncapi.yml
:
This will generate an SDK where the user would have to provide
a mandatory argument called apiKey
.
Custom API Key variable name
If you want to control variable naming and the environment variable to scan, use the configuration below:
Basic security scheme
Start by defining a basic
security scheme in your asyncapi.yml
:
This will generate an SDK where the user would have to provide
a username
and password
.
Custom Basic Auth variable names
If you want to control variable naming and the environment variables to scan, use the configuration below:
OAuth2 security scheme
OAuth2 authentication is supported for AsyncAPI specifications:
This will generate an SDK that supports OAuth2 flow for event-driven operations.
Multiple security schemes
You can specify multiple security schemes and apply them to different operations:
This allows different operations to use different authentication methods as needed.