22# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33#
44
5+ import logging
56from dataclasses import InitVar , dataclass , field
67from datetime import datetime , timedelta
7- from typing import Any , List , Mapping , MutableMapping , Optional , Union
8+ from typing import Any , List , Mapping , Optional , Union
89
910from airbyte_cdk .sources .declarative .auth .declarative_authenticator import DeclarativeAuthenticator
1011from airbyte_cdk .sources .declarative .interpolation .interpolated_boolean import InterpolatedBoolean
1920)
2021from airbyte_cdk .utils .datetime_helpers import AirbyteDateTime , ab_datetime_now , ab_datetime_parse
2122
23+ logger = logging .getLogger ("airbyte" )
24+
2225
2326@dataclass
2427class DeclarativeOauth2Authenticator (AbstractOauth2Authenticator , DeclarativeAuthenticator ):
@@ -30,7 +33,7 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
3033 Attributes:
3134 token_refresh_endpoint (Union[InterpolatedString, str]): The endpoint to refresh the access token
3235 client_id (Union[InterpolatedString, str]): The client id
33- client_secret (Union[InterpolatedString, str]): Client secret
36+ client_secret (Union[InterpolatedString, str]): Client secret (can be empty for APIs that support this)
3437 refresh_token (Union[InterpolatedString, str]): The token used to refresh the access token
3538 access_token_name (Union[InterpolatedString, str]): THe field to extract access token from in the response
3639 expires_in_name (Union[InterpolatedString, str]): The field to extract expires_in from in the response
@@ -201,8 +204,11 @@ def get_client_secret(self) -> str:
201204 self ._client_secret .eval (self .config ) if self ._client_secret else self ._client_secret
202205 )
203206 if not client_secret :
204- raise ValueError ("OAuthAuthenticator was unable to evaluate client_secret parameter" )
205- return client_secret # type: ignore # value will be returned as a string, or an error will be raised
207+ # We've seen some APIs allowing empty client_secret so we will only log here
208+ logger .warning (
209+ "OAuthAuthenticator was unable to evaluate client_secret parameter hence it'll be empty"
210+ )
211+ return client_secret # type: ignore # value will be returned as a string, which might be empty
206212
207213 def get_refresh_token_name (self ) -> str :
208214 return self ._refresh_token_name .eval (self .config ) # type: ignore # eval returns a string in this context
0 commit comments