diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py index c1ddd39f2506..763a7e22065f 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py @@ -803,7 +803,7 @@ def create_oauth_authenticator(self, model: OAuthAuthenticatorModel, config: Con scopes=model.scopes, token_expiry_date=model.token_expiry_date, token_expiry_date_format=model.token_expiry_date_format, # type: ignore - token_expiry_is_time_of_expiration=bool(model.token_expiry_date), + token_expiry_is_time_of_expiration=bool(model.token_expiry_date_format), token_refresh_endpoint=model.token_refresh_endpoint, config=config, parameters=model.parameters or {}, diff --git a/airbyte-cdk/python/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py b/airbyte-cdk/python/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py index 437b9e2b0356..a1c9eec8cd0e 100644 --- a/airbyte-cdk/python/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py +++ b/airbyte-cdk/python/unit_tests/sources/declarative/parsers/test_model_to_component_factory.py @@ -308,6 +308,32 @@ def test_interpolate_config(): assert authenticator.get_refresh_request_body() == {"body_field": "yoyoyo", "interpolated_body_field": "verysecrettoken"} +def test_interpolate_config_with_token_expiry_date_format(): + content = """ + authenticator: + type: OAuthAuthenticator + client_id: "some_client_id" + client_secret: "some_client_secret" + token_refresh_endpoint: "https://api.sendgrid.com/v3/auth" + refresh_token: "{{ config['apikey'] }}" + token_expiry_date_format: "%Y-%m-%d %H:%M:%S.%f+00:00" + """ + parsed_manifest = YamlDeclarativeSource._parse(content) + resolved_manifest = resolver.preprocess_manifest(parsed_manifest) + authenticator_manifest = transformer.propagate_types_and_parameters("", resolved_manifest["authenticator"], {}) + + authenticator = factory.create_component( + model_type=OAuthAuthenticatorModel, component_definition=authenticator_manifest, config=input_config + ) + + assert isinstance(authenticator, DeclarativeOauth2Authenticator) + assert authenticator.token_expiry_date_format == "%Y-%m-%d %H:%M:%S.%f+00:00" + assert authenticator.token_expiry_is_time_of_expiration + assert authenticator.client_id.eval(input_config) == "some_client_id" + assert authenticator.client_secret.string == "some_client_secret" + assert authenticator.token_refresh_endpoint.eval(input_config) == "https://api.sendgrid.com/v3/auth" + + def test_single_use_oauth_branch(): single_use_input_config = { "apikey": "verysecrettoken",