Submodules

airbyte_cdk.sources.declarative.auth.oauth module

class airbyte_cdk.sources.declarative.auth.oauth.DeclarativeOauth2Authenticator(token_refresh_endpoint: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], client_id: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], client_secret: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], config: typing.Mapping[str, typing.Any], parameters: dataclasses.InitVar[typing.Mapping[str, typing.Any]], refresh_token: typing.Optional[typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None, scopes: typing.Optional[typing.List[str]] = None, token_expiry_date: typing.Optional[typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None, token_expiry_date_format: typing.Optional[str] = None, token_expiry_is_time_of_expiration: bool = False, access_token_name: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'access_token', expires_in_name: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'expires_in', refresh_request_body: typing.Optional[typing.Mapping[str, typing.Any]] = None, grant_type: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'refresh_token', message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>)

Bases: airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth.AbstractOauth2Authenticator, airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Generates OAuth2.0 access tokens from an OAuth2.0 refresh token and client credentials based on a declarative connector configuration file. Credentials can be defined explicitly or via interpolation at runtime. The generated access token is attached to each request via the Authorization header.

token_refresh_endpoint

The endpoint to refresh the access token

Type

Union[InterpolatedString, str]

client_id

The client id

Type

Union[InterpolatedString, str]

client_secret

Client secret

Type

Union[InterpolatedString, str]

refresh_token

The token used to refresh the access token

Type

Union[InterpolatedString, str]

access_token_name

THe field to extract access token from in the response

Type

Union[InterpolatedString, str]

expires_in_name

The field to extract expires_in from in the response

Type

Union[InterpolatedString, str]

config

The user-provided configuration as specified by the source’s spec

Type

Mapping[str, Any]

scopes

The scopes to request

Type

Optional[List[str]]

token_expiry_date

The access token expiration date

Type

Optional[Union[InterpolatedString, str]]

token_expiry_date_format str

format of the datetime; provide it if expires_in is returned in datetime instead of seconds

token_expiry_is_time_of_expiration bool

set True it if expires_in is returned as time of expiration instead of the number seconds until expiration

refresh_request_body

The request body to send in the refresh request

Type

Optional[Mapping[str, Any]]

grant_type

The grant_type to request for access_token. If set to refresh_token, the refresh_token parameter has to be provided

Type

Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]

message_repository

the message repository used to emit logs on HTTP requests

Type

MessageRepository

property access_token: str

Returns the access token

access_token_name: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'access_token'
client_id: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
client_secret: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
config: Mapping[str, Any]
expires_in_name: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'expires_in'
get_access_token_name() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Field to extract access token from in the response

get_client_id() str

The client id to authenticate

get_client_secret() str

The client secret to authenticate

get_expires_in_name() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Returns the expires_in field name

get_grant_type() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Returns grant_type specified for requesting access_token

get_refresh_request_body() Mapping[str, Any]

Returns the request body to set on the refresh request

get_refresh_token() Optional[str]

The token used to refresh the access token when it expires

get_scopes() [<class 'str'>]

List of requested scopes

get_token_expiry_date() pendulum.datetime.DateTime

Expiration date of the access token

get_token_refresh_endpoint() str

Returns the endpoint to refresh the access token

grant_type: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'refresh_token'
message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>
parameters: dataclasses.InitVar[Mapping[str, Any]]
refresh_request_body: Optional[Mapping[str, Any]] = None
refresh_token: Optional[Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None
scopes: Optional[List[str]] = None
set_token_expiry_date(value: Union[str, int])

Setter for access token expiration date

token_expiry_date: Optional[Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None
token_expiry_date_format: str = None
token_expiry_is_time_of_expiration: bool = False
token_refresh_endpoint: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
class airbyte_cdk.sources.declarative.auth.oauth.DeclarativeSingleUseRefreshTokenOauth2Authenticator(*args, **kwargs)

Bases: airbyte_cdk.sources.streams.http.requests_native_auth.oauth.SingleUseRefreshTokenOauth2Authenticator, airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Declarative version of SingleUseRefreshTokenOauth2Authenticator which can be used in declarative connectors.

airbyte_cdk.sources.declarative.auth.token module

class airbyte_cdk.sources.declarative.auth.token.ApiKeyAuthenticator(request_option: airbyte_cdk.sources.declarative.requesters.request_option.RequestOption, token_provider: airbyte_cdk.sources.declarative.auth.token_provider.TokenProvider, config: Mapping[str, Any], parameters: dataclasses.InitVar[Mapping[str, Any]])

Bases: airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

ApiKeyAuth sets a request header on the HTTP requests sent.

The header is of the form: “<header>”: “<token>”

For example, ApiKeyAuthenticator(“Authorization”, “Bearer hello”) will result in the following header set on the HTTP request “Authorization”: “Bearer hello”

request_option

request option how to inject the token into the request

Type

RequestOption

token_provider

Provider of the token

Type

TokenProvider

config

The user-provided configuration as specified by the source’s spec

Type

Config

parameters

Additional runtime parameters to be used for string interpolation

Type

Mapping[str, Any]

property auth_header: str

HTTP header to set on the requests

config: Mapping[str, Any]
get_request_body_data() Union[Mapping[str, Any], str]

Form-encoded body data to set on the requests

get_request_body_json() Mapping[str, Any]

JSON-encoded body data to set on the requests

get_request_params() Mapping[str, Any]

HTTP request parameter to add to the requests

parameters: dataclasses.InitVar[Mapping[str, Any]]
request_option: airbyte_cdk.sources.declarative.requesters.request_option.RequestOption
property token: str

The header value to set on outgoing HTTP requests

token_provider: airbyte_cdk.sources.declarative.auth.token_provider.TokenProvider
class airbyte_cdk.sources.declarative.auth.token.BasicHttpAuthenticator(username: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], config: Mapping[str, Any], parameters: dataclasses.InitVar[Mapping[str, Any]], password: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = '')

Bases: airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Builds auth based off the basic authentication scheme as defined by RFC 7617, which transmits credentials as USER ID/password pairs, encoded using base64 https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#basic_authentication_scheme

The header is of the form “Authorization”: “Basic <encoded_credentials>”

username

The username

Type

Union[InterpolatedString, str]

config

The user-provided configuration as specified by the source’s spec

Type

Config

password

The password

Type

Union[InterpolatedString, str]

parameters

Additional runtime parameters to be used for string interpolation

Type

Mapping[str, Any]

property auth_header: str

HTTP header to set on the requests

config: Mapping[str, Any]
parameters: dataclasses.InitVar[Mapping[str, Any]]
password: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = ''
property token: str

The header value to set on outgoing HTTP requests

username: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
class airbyte_cdk.sources.declarative.auth.token.BearerAuthenticator(token_provider: airbyte_cdk.sources.declarative.auth.token_provider.TokenProvider, config: Mapping[str, Any], parameters: dataclasses.InitVar[Mapping[str, Any]])

Bases: airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Authenticator that sets the Authorization header on the HTTP requests sent.

The header is of the form: “Authorization”: “Bearer <token>”

token_provider

Provider of the token

Type

TokenProvider

config

The user-provided configuration as specified by the source’s spec

Type

Config

parameters

Additional runtime parameters to be used for string interpolation

Type

Mapping[str, Any]

property auth_header: str

HTTP header to set on the requests

config: Mapping[str, Any]
parameters: dataclasses.InitVar[Mapping[str, Any]]
property token: str

The header value to set on outgoing HTTP requests

token_provider: airbyte_cdk.sources.declarative.auth.token_provider.TokenProvider
class airbyte_cdk.sources.declarative.auth.token.LegacySessionTokenAuthenticator(api_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], header: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], session_token: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], session_token_response_key: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], username: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], config: Mapping[str, Any], parameters: dataclasses.InitVar[Mapping[str, Any]], login_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], validate_session_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], password: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = '')

Bases: airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Builds auth based on session tokens. A session token is a random value generated by a server to identify a specific user for the duration of one interaction session.

The header is of the form “Specific Header”: “Session Token Value”

api_url

Base api url of source

Type

Union[InterpolatedString, str]

username

The username

Type

Union[InterpolatedString, str]

config

The user-provided configuration as specified by the source’s spec

Type

Config

password

The password

Type

Union[InterpolatedString, str]

header

Specific header of source for providing session token

Type

Union[InterpolatedString, str]

parameters

Additional runtime parameters to be used for string interpolation

Type

Mapping[str, Any]

session_token

Session token generated by user

Type

Union[InterpolatedString, str]

session_token_response_key

Key for retrieving session token from api response

Type

Union[InterpolatedString, str]

login_url

Url fot getting a specific session token

Type

Union[InterpolatedString, str]

validate_session_url

Url to validate passed session token

Type

Union[InterpolatedString, str]

api_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
property auth_header: str

HTTP header to set on the requests

config: Mapping[str, Any]
header: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
is_valid_session_token() bool
login_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
parameters: dataclasses.InitVar[Mapping[str, Any]]
password: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = ''
session_token: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
session_token_response_key: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
property token: str

The header value to set on outgoing HTTP requests

username: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
validate_session_url: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
airbyte_cdk.sources.declarative.auth.token.get_new_session_token(api_url: str, username: str, password: str, response_key: str) str

This method retrieves session token from api by username and password for SessionTokenAuthenticator. It’s cashed to avoid a multiple calling by sync and updating session token every stream sync. :param api_url: api url for getting new session token :param username: username for auth :param password: password for auth :param response_key: field name in response to retrieve a session token

Returns

session token

Module contents

class airbyte_cdk.sources.declarative.auth.DeclarativeOauth2Authenticator(token_refresh_endpoint: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], client_id: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], client_secret: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str], config: typing.Mapping[str, typing.Any], parameters: dataclasses.InitVar[typing.Mapping[str, typing.Any]], refresh_token: typing.Optional[typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None, scopes: typing.Optional[typing.List[str]] = None, token_expiry_date: typing.Optional[typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None, token_expiry_date_format: typing.Optional[str] = None, token_expiry_is_time_of_expiration: bool = False, access_token_name: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'access_token', expires_in_name: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'expires_in', refresh_request_body: typing.Optional[typing.Mapping[str, typing.Any]] = None, grant_type: typing.Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'refresh_token', message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>)

Bases: airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth.AbstractOauth2Authenticator, airbyte_cdk.sources.declarative.auth.declarative_authenticator.DeclarativeAuthenticator

Generates OAuth2.0 access tokens from an OAuth2.0 refresh token and client credentials based on a declarative connector configuration file. Credentials can be defined explicitly or via interpolation at runtime. The generated access token is attached to each request via the Authorization header.

token_refresh_endpoint

The endpoint to refresh the access token

Type

Union[InterpolatedString, str]

client_id

The client id

Type

Union[InterpolatedString, str]

client_secret

Client secret

Type

Union[InterpolatedString, str]

refresh_token

The token used to refresh the access token

Type

Union[InterpolatedString, str]

access_token_name

THe field to extract access token from in the response

Type

Union[InterpolatedString, str]

expires_in_name

The field to extract expires_in from in the response

Type

Union[InterpolatedString, str]

config

The user-provided configuration as specified by the source’s spec

Type

Mapping[str, Any]

scopes

The scopes to request

Type

Optional[List[str]]

token_expiry_date

The access token expiration date

Type

Optional[Union[InterpolatedString, str]]

token_expiry_date_format str

format of the datetime; provide it if expires_in is returned in datetime instead of seconds

token_expiry_is_time_of_expiration bool

set True it if expires_in is returned as time of expiration instead of the number seconds until expiration

refresh_request_body

The request body to send in the refresh request

Type

Optional[Mapping[str, Any]]

grant_type

The grant_type to request for access_token. If set to refresh_token, the refresh_token parameter has to be provided

Type

Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]

message_repository

the message repository used to emit logs on HTTP requests

Type

MessageRepository

property access_token: str

Returns the access token

access_token_name: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'access_token'
client_id: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
client_secret: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]
config: Mapping[str, Any]
expires_in_name: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'expires_in'
get_access_token_name() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Field to extract access token from in the response

get_client_id() str

The client id to authenticate

get_client_secret() str

The client secret to authenticate

get_expires_in_name() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Returns the expires_in field name

get_grant_type() airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString

Returns grant_type specified for requesting access_token

get_refresh_request_body() Mapping[str, Any]

Returns the request body to set on the refresh request

get_refresh_token() Optional[str]

The token used to refresh the access token when it expires

get_scopes() [<class 'str'>]

List of requested scopes

get_token_expiry_date() pendulum.datetime.DateTime

Expiration date of the access token

get_token_refresh_endpoint() str

Returns the endpoint to refresh the access token

grant_type: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str] = 'refresh_token'
message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>
parameters: dataclasses.InitVar[Mapping[str, Any]]
refresh_request_body: Optional[Mapping[str, Any]] = None
refresh_token: Optional[Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None
scopes: Optional[List[str]] = None
set_token_expiry_date(value: Union[str, int])

Setter for access token expiration date

token_expiry_date: Optional[Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]] = None
token_expiry_date_format: str = None
token_expiry_is_time_of_expiration: bool = False
token_refresh_endpoint: Union[airbyte_cdk.sources.declarative.interpolation.interpolated_string.InterpolatedString, str]