Submodules
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth module
- class airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth.AbstractOauth2Authenticator
Bases:
requests.auth.AuthBase
Abstract class for an OAuth authenticators that implements the OAuth token refresh flow. The authenticator is designed to generically perform the refresh flow without regard to how config fields are get/set by delegating that behavior to the classes implementing the interface.
- abstract property access_token: str
Returns the access token
- build_refresh_request_body() Mapping[str, Any]
Returns the request body to set on the refresh request
Override to define additional parameters
- get_access_token() str
Returns the access token
- abstract get_access_token_name() str
Field to extract access token from in the response
- get_auth_header() Mapping[str, Any]
HTTP header to set on the requests
- abstract get_client_id() str
The client id to authenticate
- abstract get_client_secret() str
The client secret to authenticate
- abstract get_expires_in_name() str
Returns the expires_in field name
- abstract get_grant_type() str
Returns grant_type specified for requesting access_token
- abstract get_refresh_request_body() Mapping[str, Any]
Returns the request body to set on the refresh request
- abstract get_refresh_token() Optional[str]
The token used to refresh the access token when it expires
- abstract get_scopes() List[str]
List of requested scopes
- abstract get_token_expiry_date() pendulum.datetime.DateTime
Expiration date of the access token
- abstract get_token_refresh_endpoint() str
Returns the endpoint to refresh the access token
- refresh_access_token() Tuple[str, int]
Returns the refresh token and its lifespan in seconds
- Returns
a tuple of (access_token, token_lifespan_in_seconds)
- abstract set_token_expiry_date(value: Union[str, int])
Setter for access token expiration date
- token_has_expired() bool
Returns True if the token is expired
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token module
- class airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Bases:
requests.auth.AuthBase
Abstract class for an header-based authenticators that add a header to outgoing HTTP requests.
- abstract property auth_header: str
HTTP header to set on the requests
- get_auth_header() Mapping[str, Any]
The header to set on outgoing HTTP requests
- abstract property token: str
The header value to set on outgoing HTTP requests
airbyte_cdk.sources.streams.http.requests_native_auth.oauth module
- class airbyte_cdk.sources.streams.http.requests_native_auth.oauth.Oauth2Authenticator(token_refresh_endpoint: str, client_id: str, client_secret: str, refresh_token: str, scopes: Optional[List[str]] = None, token_expiry_date: Optional[pendulum.datetime.DateTime] = None, token_expiry_date_format: Optional[str] = None, access_token_name: str = 'access_token', expires_in_name: str = 'expires_in', refresh_request_body: Optional[Mapping[str, Any]] = None, grant_type: str = 'refresh_token')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth.AbstractOauth2Authenticator
Generates OAuth2.0 access tokens from an OAuth2.0 refresh token and client credentials. The generated access token is attached to each request via the Authorization header. If a connector_config is provided any mutation of it’s value in the scope of this class will emit AirbyteControlConnectorConfigMessage.
- property access_token: str
Returns the access token
- get_access_token_name() str
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() str
Returns the expires_in field name
- get_grant_type() str
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() 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
- set_token_expiry_date(value: Union[str, int])
Setter for access token expiration date
- class airbyte_cdk.sources.streams.http.requests_native_auth.oauth.SingleUseRefreshTokenOauth2Authenticator(connector_config: typing.Mapping[str, typing.Any], token_refresh_endpoint: str, scopes: typing.Optional[typing.List[str]] = None, access_token_name: str = 'access_token', expires_in_name: str = 'expires_in', refresh_token_name: str = 'refresh_token', refresh_request_body: typing.Optional[typing.Mapping[str, typing.Any]] = None, grant_type: str = 'refresh_token', client_id: typing.Optional[str] = None, client_secret: typing.Optional[str] = None, access_token_config_path: typing.Sequence[str] = ('credentials', 'access_token'), refresh_token_config_path: typing.Sequence[str] = ('credentials', 'refresh_token'), token_expiry_date_config_path: typing.Sequence[str] = ('credentials', 'token_expiry_date'), token_expiry_date_format: typing.Optional[str] = None, message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>)
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.oauth.Oauth2Authenticator
Authenticator that should be used for API implementing single use refresh tokens: when refreshing access token some API returns a new refresh token that needs to used in the next refresh flow. This authenticator updates the configuration with new refresh token by emitting Airbyte control message from an observed mutation. By default this authenticator expects a connector config with a”credentials” field with the following nested fields: client_id, client_secret, refresh_token. This behavior can be changed by defining custom config path (using dpath paths) in client_id_config_path, client_secret_config_path, refresh_token_config_path constructor arguments.
- property access_token: str
Returns the access token
- get_access_token() str
Retrieve new access and refresh token if the access token has expired. The new refresh token is persisted with the set_refresh_token function :returns: The current access_token, updated if it was previously expired. :rtype: str
- get_client_id() str
The client id to authenticate
- get_client_secret() str
The client secret to authenticate
- static get_new_token_expiry_date(access_token_expires_in: str, token_expiry_date_format: Optional[str] = None) pendulum.datetime.DateTime
- get_refresh_token() str
The token used to refresh the access token when it expires
- get_refresh_token_name() str
- get_token_expiry_date() pendulum.datetime.DateTime
Expiration date of the access token
- refresh_access_token() Tuple[str, str, str]
Returns the refresh token and its lifespan in seconds
- Returns
a tuple of (access_token, token_lifespan_in_seconds)
- set_refresh_token(new_refresh_token: str)
- set_token_expiry_date(new_token_expiry_date)
Setter for access token expiration date
- token_has_expired() bool
Returns True if the token is expired
airbyte_cdk.sources.streams.http.requests_native_auth.token module
- class airbyte_cdk.sources.streams.http.requests_native_auth.token.BasicHttpAuthenticator(username: str, password: str = '', auth_method: str = 'Basic', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth based off the basic authentication scheme as defined by RFC 7617, which transmits credentials as USER ID/password pairs, encoded using bas64 https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#basic_authentication_scheme
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests
- class airbyte_cdk.sources.streams.http.requests_native_auth.token.MultipleTokenAuthenticator(tokens: List[str], auth_method: str = 'Bearer', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth header, based on the list of tokens provided. Auth header is changed per each get_auth_header call, using each token in cycle. The token is attached to each request via the auth_header header.
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests
- class airbyte_cdk.sources.streams.http.requests_native_auth.token.TokenAuthenticator(token: str, auth_method: str = 'Bearer', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth header, based on the token provided. The token is attached to each request via the auth_header header.
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests
Module contents
- class airbyte_cdk.sources.streams.http.requests_native_auth.BasicHttpAuthenticator(username: str, password: str = '', auth_method: str = 'Basic', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth based off the basic authentication scheme as defined by RFC 7617, which transmits credentials as USER ID/password pairs, encoded using bas64 https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#basic_authentication_scheme
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests
- class airbyte_cdk.sources.streams.http.requests_native_auth.MultipleTokenAuthenticator(tokens: List[str], auth_method: str = 'Bearer', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth header, based on the list of tokens provided. Auth header is changed per each get_auth_header call, using each token in cycle. The token is attached to each request via the auth_header header.
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests
- class airbyte_cdk.sources.streams.http.requests_native_auth.Oauth2Authenticator(token_refresh_endpoint: str, client_id: str, client_secret: str, refresh_token: str, scopes: Optional[List[str]] = None, token_expiry_date: Optional[pendulum.datetime.DateTime] = None, token_expiry_date_format: Optional[str] = None, access_token_name: str = 'access_token', expires_in_name: str = 'expires_in', refresh_request_body: Optional[Mapping[str, Any]] = None, grant_type: str = 'refresh_token')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_oauth.AbstractOauth2Authenticator
Generates OAuth2.0 access tokens from an OAuth2.0 refresh token and client credentials. The generated access token is attached to each request via the Authorization header. If a connector_config is provided any mutation of it’s value in the scope of this class will emit AirbyteControlConnectorConfigMessage.
- property access_token: str
Returns the access token
- get_access_token_name() str
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() str
Returns the expires_in field name
- get_grant_type() str
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() 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
- set_token_expiry_date(value: Union[str, int])
Setter for access token expiration date
- class airbyte_cdk.sources.streams.http.requests_native_auth.SingleUseRefreshTokenOauth2Authenticator(connector_config: typing.Mapping[str, typing.Any], token_refresh_endpoint: str, scopes: typing.Optional[typing.List[str]] = None, access_token_name: str = 'access_token', expires_in_name: str = 'expires_in', refresh_token_name: str = 'refresh_token', refresh_request_body: typing.Optional[typing.Mapping[str, typing.Any]] = None, grant_type: str = 'refresh_token', client_id: typing.Optional[str] = None, client_secret: typing.Optional[str] = None, access_token_config_path: typing.Sequence[str] = ('credentials', 'access_token'), refresh_token_config_path: typing.Sequence[str] = ('credentials', 'refresh_token'), token_expiry_date_config_path: typing.Sequence[str] = ('credentials', 'token_expiry_date'), token_expiry_date_format: typing.Optional[str] = None, message_repository: airbyte_cdk.sources.message.repository.MessageRepository = <airbyte_cdk.sources.message.repository.NoopMessageRepository object>)
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.oauth.Oauth2Authenticator
Authenticator that should be used for API implementing single use refresh tokens: when refreshing access token some API returns a new refresh token that needs to used in the next refresh flow. This authenticator updates the configuration with new refresh token by emitting Airbyte control message from an observed mutation. By default this authenticator expects a connector config with a”credentials” field with the following nested fields: client_id, client_secret, refresh_token. This behavior can be changed by defining custom config path (using dpath paths) in client_id_config_path, client_secret_config_path, refresh_token_config_path constructor arguments.
- property access_token: str
Returns the access token
- get_access_token() str
Retrieve new access and refresh token if the access token has expired. The new refresh token is persisted with the set_refresh_token function :returns: The current access_token, updated if it was previously expired. :rtype: str
- get_client_id() str
The client id to authenticate
- get_client_secret() str
The client secret to authenticate
- static get_new_token_expiry_date(access_token_expires_in: str, token_expiry_date_format: Optional[str] = None) pendulum.datetime.DateTime
- get_refresh_token() str
The token used to refresh the access token when it expires
- get_refresh_token_name() str
- get_token_expiry_date() pendulum.datetime.DateTime
Expiration date of the access token
- refresh_access_token() Tuple[str, str, str]
Returns the refresh token and its lifespan in seconds
- Returns
a tuple of (access_token, token_lifespan_in_seconds)
- set_refresh_token(new_refresh_token: str)
- set_token_expiry_date(new_token_expiry_date)
Setter for access token expiration date
- token_has_expired() bool
Returns True if the token is expired
- class airbyte_cdk.sources.streams.http.requests_native_auth.TokenAuthenticator(token: str, auth_method: str = 'Bearer', auth_header: str = 'Authorization')
Bases:
airbyte_cdk.sources.streams.http.requests_native_auth.abstract_token.AbstractHeaderAuthenticator
Builds auth header, based on the token provided. The token is attached to each request via the auth_header header.
- property auth_header: str
HTTP header to set on the requests
- property token: str
The header value to set on outgoing HTTP requests