Learn how to use the SDK to build integrations with different authorization styles.
Credentials model vs. legacy single auth*This page has been updated with the latest SDK principles, mainly concerning the usage of the credentials model for using multiple credentials inside a connector. For the old and still supported auth property (single credential) scroll to the bottom of the page.Recommended Principles
- Declare every credential up front: A connector lists all the credentials it accepts in a dedicated
auth.pyfile. This is the default for new connectors and is what the scaffold generates. - OAuth2 Preference: OAuth2 is the preferred authentication method for Lumos connectors due to its security and flexibility.
- Credential Readiness: Connectors expect authentication credentials to be ready for use. The connector SDK has a fully fledged OAuth module which handles the specific authorization capabilities.
- Standardized Implementation: Credentials are turned into an authenticated HTTP client inside
client.pyduring its initialization, and the SDK offers pre-defined models for the most common authentication schemes.
Why Multiple Credentials
Apps frequently need more than one credential for a single connection. A common shape is OAuth for the app’s REST API plus a separate SCIM token for user provisioning, sometimes with a third credential unlocking an optional area of the API such as license management. Rather than packing extra secrets into the settings object, a connector declares each credential explicitly. Each one gets its own ID, its own setup instructions, and its own client. Lumos then knows which combinations of credentials form a valid connection, which fields are secret, and how to validate each one as the customer enters it.OAuth2 Authentication Flow
The general process is as follows:- The user initiates the OAuth flow with the third-party service, using a
Connectbutton in Lumos. - After successful authentication, the service provides an access token.
- This access token, along with any other required credentials, is saved and later on passed to the Lumos connector.
- The connector uses these credentials for all subsequent API requests.
Implementing Authentication
Declaring credentials (auth.py)
Each credential is a CredentialConfig, or an OAuthConfig when it uses an OAuth flow. The list is the connector’s public authentication contract:
constants.py:
CredentialConfig accepts:
Available authentication models:
Integration Configuration
Inintegration.py, pass the credential list as credentials and declare which combinations form a valid connection:
allowed_credentials is one combination a single connection may use. To offer OAuth alone or OAuth plus SCIM, list both:
allowed_credentials, the combinations are derived from the optional flag on each credential: required credentials are always requested together, and each optional credential is additionally offered on its own. Being explicit is clearer whenever more than one credential is involved.
The OAuthConfig entries drive the OAuth module, so get_authorization_url, handle_authorization_callback, handle_client_credentials_request and refresh_access_token are registered automatically. OAuth settings now live on each credential, so the top-level oauth_settings argument on the Integration is not used by connectors on the credentials model. When a connector declares more than one OAuth credential, those capabilities accept a credential_id so the right settings are selected.
Client class
Each connector implements a client class, extending theBaseIntegrationClient SDK class, in a dedicated client.py file. get_credential pulls a specific credential out of the request by ID:
BaseIntegrationClient class serves as the minimal abstraction layer for writing a httpx AsyncClient implementation. The prepare_client_args class method then provides arguments for httpx to initialize.
Each credential often has its own auth scheme and its own base URL, so you can add a second class rather than branching inside prepare_client_args:
optional=True, pass strict=False and handle its absence with an actionable error:
strict=False, a missing credential raises — which is the behavior you want for credentials that are always required.
Validating a credential as it is entered
Attachingvalidation= to a CredentialConfig registers a validator for the validate_credential_config capability. It runs against the single credential the user just entered, before the connection is saved, and anything it returns in validation_errors is shown to them verbatim.
- credentials missing required fields
- required fields submitted as empty strings
- values with leading or trailing whitespace
- payloads that do not match the declared authentication model
async. The validate_credential_config capability itself is registered automatically for you; set CredentialsSettings(register_validation_capability=False) only if you need to implement it by hand.
Customizing credential fields
Useinput_model when the default payload model does not carry the fields the app needs, or when you want to add customer-facing titles and descriptions to them.
Token Based Authentication
- Extends
TokenCredentialfor token-based authentication. - Uses
AnnotatedFieldto ensure secure handling of the token, using thesecretargument.
Basic Authentication
- Extends
BasicCredentialfor basic authentication. - Uses
AnnotatedFieldto ensure secure handling of the password, using thesecretargument.
OAuth Client Credentials Flow
Sometimes called machine to machine flow, this OAuth flow is widely used for server-side communication. It requires the caller to authorize and obtain an access_token in a single request-response flow.
OAuthClientCredential model and use the SDK provided OAuth module.
Best Practices
- Security: Use appropriate field types (e.g.
AnnotatedFieldwith arguments likehidden— hidden from the end user, for example when not needed — andsecretfor sensitive values) for sensitive information. - Write instructions for a person: The
descriptionon each credential is what a user follows during setup and how your connector describes itself in its OAS. - Split by credential, not by branch: One
CredentialConfigand one client class per credential keeps auth concerns isolated, if possible. - Be honest about optionality: Mark a credential
optional=Trueonly if the connector genuinely functions without it, and raiseMissingParameterErrorwith ahintwhen a capability needs it. - Validate fast up front, properly later: Single credential checks in
validate_credential_config, full credential combination API checks invalidate_credentials. - Extensibility: Design your authentication and settings models to be extensible as API requirements change.
- Validation: Leverage Pydantic’s validation capabilities to ensure that provided credentials and settings meet the required format and constraints.
Connector Specific Considerations
- While the general structure remains consistent, each connector may have unique authentication requirements.
- Always refer to the specific API documentation of the service you’re integrating with for the most accurate authentication requirements.
- If you require multiple authentication credentials, it is recommended to append the extra credentials to the Settings object using appropriate secret arguments.
Legacy: Single-Credential Connectors
Legacy: Single-Credential Connectors
Connectors written before the credentials model accept exactly one credential. They pass a single payload model as In this shape, custom credential models are conventionally defined in
auth, configure OAuth with a top-level oauth_settings, and read the credential with get_oauth(args), get_token_auth(args) or get_basic_auth(args):settings.py rather than auth.py, and requests carry the credential on a single auth object instead of a credentials array.This shape remains supported, and the SDK scaffold can still generate it with connector scaffold <name> <directory> --single-auth. New connectors should prefer the credentials model: it is the only shape that supports more than one credential, and validate_credential_config.Connector Specific Considerations
- While the general structure remains consistent, each connector may have unique authentication requirements.
- Always refer to the specific API documentation of the service you’re integrating with for the most accurate authentication requirements.
- If you require multiple authentication credentials, declare each one in
auth.pyrather than appending extra secrets to the Settings object.