airbyte-cdk 6.19.0__py3-none-any.whl → 6.19.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,7 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
39
39
  token_expiry_date_format str: format of the datetime; provide it if expires_in is returned in datetime instead of seconds
40
40
  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
41
41
  refresh_request_body (Optional[Mapping[str, Any]]): The request body to send in the refresh request
42
+ refresh_request_headers (Optional[Mapping[str, Any]]): The request headers to send in the refresh request
42
43
  grant_type: The grant_type to request for access_token. If set to refresh_token, the refresh_token parameter has to be provided
43
44
  message_repository (MessageRepository): the message repository used to emit logs on HTTP requests
44
45
  """
@@ -61,6 +62,7 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
61
62
  expires_in_name: Union[InterpolatedString, str] = "expires_in"
62
63
  refresh_token_name: Union[InterpolatedString, str] = "refresh_token"
63
64
  refresh_request_body: Optional[Mapping[str, Any]] = None
65
+ refresh_request_headers: Optional[Mapping[str, Any]] = None
64
66
  grant_type_name: Union[InterpolatedString, str] = "grant_type"
65
67
  grant_type: Union[InterpolatedString, str] = "refresh_token"
66
68
  message_repository: MessageRepository = NoopMessageRepository()
@@ -101,6 +103,9 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
101
103
  self._refresh_request_body = InterpolatedMapping(
102
104
  self.refresh_request_body or {}, parameters=parameters
103
105
  )
106
+ self._refresh_request_headers = InterpolatedMapping(
107
+ self.refresh_request_headers or {}, parameters=parameters
108
+ )
104
109
  self._token_expiry_date: pendulum.DateTime = (
105
110
  pendulum.parse(
106
111
  InterpolatedString.create(self.token_expiry_date, parameters=parameters).eval(
@@ -178,6 +183,9 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
178
183
  def get_refresh_request_body(self) -> Mapping[str, Any]:
179
184
  return self._refresh_request_body.eval(self.config)
180
185
 
186
+ def get_refresh_request_headers(self) -> Mapping[str, Any]:
187
+ return self._refresh_request_headers.eval(self.config)
188
+
181
189
  def get_token_expiry_date(self) -> pendulum.DateTime:
182
190
  return self._token_expiry_date # type: ignore # _token_expiry_date is a pendulum.DateTime. It is never None despite what mypy thinks
183
191
 
@@ -1139,6 +1139,14 @@ definitions:
1139
1139
  - applicationId: "{{ config['application_id'] }}"
1140
1140
  applicationSecret: "{{ config['application_secret'] }}"
1141
1141
  token: "{{ config['token'] }}"
1142
+ refresh_request_headers:
1143
+ title: Refresh Request Headers
1144
+ description: Headers of the request sent to get a new access token.
1145
+ type: object
1146
+ additionalProperties: true
1147
+ examples:
1148
+ - Authorization: "<AUTH_TOKEN>"
1149
+ Content-Type: "application/x-www-form-urlencoded"
1142
1150
  scopes:
1143
1151
  title: Scopes
1144
1152
  description: List of scopes that should be granted to the access token.
@@ -571,6 +571,17 @@ class OAuthAuthenticator(BaseModel):
571
571
  ],
572
572
  title="Refresh Request Body",
573
573
  )
574
+ refresh_request_headers: Optional[Dict[str, Any]] = Field(
575
+ None,
576
+ description="Headers of the request sent to get a new access token.",
577
+ examples=[
578
+ {
579
+ "Authorization": "<AUTH_TOKEN>",
580
+ "Content-Type": "application/x-www-form-urlencoded",
581
+ }
582
+ ],
583
+ title="Refresh Request Headers",
584
+ )
574
585
  scopes: Optional[List[str]] = Field(
575
586
  None,
576
587
  description="List of scopes that should be granted to the access token.",
@@ -1919,6 +1919,9 @@ class ModelToComponentFactory:
1919
1919
  refresh_request_body=InterpolatedMapping(
1920
1920
  model.refresh_request_body or {}, parameters=model.parameters or {}
1921
1921
  ).eval(config),
1922
+ refresh_request_headers=InterpolatedMapping(
1923
+ model.refresh_request_headers or {}, parameters=model.parameters or {}
1924
+ ).eval(config),
1922
1925
  scopes=model.scopes,
1923
1926
  token_expiry_date_format=model.token_expiry_date_format,
1924
1927
  message_repository=self._message_repository,
@@ -1938,6 +1941,7 @@ class ModelToComponentFactory:
1938
1941
  grant_type_name=model.grant_type_name or "grant_type",
1939
1942
  grant_type=model.grant_type or "refresh_token",
1940
1943
  refresh_request_body=model.refresh_request_body,
1944
+ refresh_request_headers=model.refresh_request_headers,
1941
1945
  refresh_token_name=model.refresh_token_name or "refresh_token",
1942
1946
  refresh_token=model.refresh_token,
1943
1947
  scopes=model.scopes,
@@ -98,6 +98,14 @@ class AbstractOauth2Authenticator(AuthBase):
98
98
 
99
99
  return payload
100
100
 
101
+ def build_refresh_request_headers(self) -> Mapping[str, Any] | None:
102
+ """
103
+ Returns the request headers to set on the refresh request
104
+
105
+ """
106
+ headers = self.get_refresh_request_headers()
107
+ return headers if headers else None
108
+
101
109
  def _wrap_refresh_token_exception(
102
110
  self, exception: requests.exceptions.RequestException
103
111
  ) -> bool:
@@ -128,6 +136,7 @@ class AbstractOauth2Authenticator(AuthBase):
128
136
  method="POST",
129
137
  url=self.get_token_refresh_endpoint(), # type: ignore # returns None, if not provided, but str | bytes is expected.
130
138
  data=self.build_refresh_request_body(),
139
+ headers=self.build_refresh_request_headers(),
131
140
  )
132
141
  if response.ok:
133
142
  response_json = response.json()
@@ -254,6 +263,10 @@ class AbstractOauth2Authenticator(AuthBase):
254
263
  def get_refresh_request_body(self) -> Mapping[str, Any]:
255
264
  """Returns the request body to set on the refresh request"""
256
265
 
266
+ @abstractmethod
267
+ def get_refresh_request_headers(self) -> Mapping[str, Any]:
268
+ """Returns the request headers to set on the refresh request"""
269
+
257
270
  @abstractmethod
258
271
  def get_grant_type(self) -> str:
259
272
  """Returns grant_type specified for requesting access_token"""
@@ -39,6 +39,7 @@ class Oauth2Authenticator(AbstractOauth2Authenticator):
39
39
  access_token_name: str = "access_token",
40
40
  expires_in_name: str = "expires_in",
41
41
  refresh_request_body: Mapping[str, Any] | None = None,
42
+ refresh_request_headers: Mapping[str, Any] | None = None,
42
43
  grant_type_name: str = "grant_type",
43
44
  grant_type: str = "refresh_token",
44
45
  token_expiry_is_time_of_expiration: bool = False,
@@ -57,6 +58,7 @@ class Oauth2Authenticator(AbstractOauth2Authenticator):
57
58
  self._access_token_name = access_token_name
58
59
  self._expires_in_name = expires_in_name
59
60
  self._refresh_request_body = refresh_request_body
61
+ self._refresh_request_headers = refresh_request_headers
60
62
  self._grant_type_name = grant_type_name
61
63
  self._grant_type = grant_type
62
64
 
@@ -101,6 +103,9 @@ class Oauth2Authenticator(AbstractOauth2Authenticator):
101
103
  def get_refresh_request_body(self) -> Mapping[str, Any]:
102
104
  return self._refresh_request_body # type: ignore [return-value]
103
105
 
106
+ def get_refresh_request_headers(self) -> Mapping[str, Any]:
107
+ return self._refresh_request_headers # type: ignore [return-value]
108
+
104
109
  def get_grant_type_name(self) -> str:
105
110
  return self._grant_type_name
106
111
 
@@ -149,6 +154,7 @@ class SingleUseRefreshTokenOauth2Authenticator(Oauth2Authenticator):
149
154
  expires_in_name: str = "expires_in",
150
155
  refresh_token_name: str = "refresh_token",
151
156
  refresh_request_body: Mapping[str, Any] | None = None,
157
+ refresh_request_headers: Mapping[str, Any] | None = None,
152
158
  grant_type_name: str = "grant_type",
153
159
  grant_type: str = "refresh_token",
154
160
  client_id_name: str = "client_id",
@@ -174,6 +180,7 @@ class SingleUseRefreshTokenOauth2Authenticator(Oauth2Authenticator):
174
180
  expires_in_name (str, optional): Name of the name of the field that characterizes when the current access token will expire, used to parse the refresh token response. Defaults to "expires_in".
175
181
  refresh_token_name (str, optional): Name of the name of the refresh token field, used to parse the refresh token response. Defaults to "refresh_token".
176
182
  refresh_request_body (Mapping[str, Any], optional): Custom key value pair that will be added to the refresh token request body. Defaults to None.
183
+ refresh_request_headers (Mapping[str, Any], optional): Custom key value pair that will be added to the refresh token request headers. Defaults to None.
177
184
  grant_type (str, optional): OAuth grant type. Defaults to "refresh_token".
178
185
  client_id (Optional[str]): The client id to authenticate. If not specified, defaults to credentials.client_id in the config object.
179
186
  client_secret (Optional[str]): The client secret to authenticate. If not specified, defaults to credentials.client_secret in the config object.
@@ -220,6 +227,7 @@ class SingleUseRefreshTokenOauth2Authenticator(Oauth2Authenticator):
220
227
  access_token_name=access_token_name,
221
228
  expires_in_name=expires_in_name,
222
229
  refresh_request_body=refresh_request_body,
230
+ refresh_request_headers=refresh_request_headers,
223
231
  grant_type_name=self._grant_type_name,
224
232
  grant_type=grant_type,
225
233
  token_expiry_date_format=token_expiry_date_format,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: airbyte-cdk
3
- Version: 6.19.0
3
+ Version: 6.19.1
4
4
  Summary: A framework for writing Airbyte Connectors.
5
5
  License: MIT
6
6
  Keywords: airbyte,connector-development-kit,cdk
@@ -53,7 +53,7 @@ airbyte_cdk/sources/declarative/async_job/timer.py,sha256=Fb8P72CQ7jIzJyzMSSNuBf
53
53
  airbyte_cdk/sources/declarative/auth/__init__.py,sha256=e2CRrcBWGhz3sQu3Oh34d1riEIwXipGS8hrSB1pu0Oo,284
54
54
  airbyte_cdk/sources/declarative/auth/declarative_authenticator.py,sha256=nf-OmRUHYG4ORBwyb5CANzuHEssE-oNmL-Lccn41Td8,1099
55
55
  airbyte_cdk/sources/declarative/auth/jwt.py,sha256=7r5q1zOekjw8kEmEk1oUyovzVt3cbD6BuFnRILeLZi8,8250
56
- airbyte_cdk/sources/declarative/auth/oauth.py,sha256=EDx-tY0ZhBXe6yVHkqjUAqMWJAl4rQXjQbr4rElt_Ds,10555
56
+ airbyte_cdk/sources/declarative/auth/oauth.py,sha256=GhXWheC5GkKV7req3jBCY0aTbFwCuQ5RRSfZi3jFphM,11002
57
57
  airbyte_cdk/sources/declarative/auth/selective_authenticator.py,sha256=qGwC6YsCldr1bIeKG6Qo-A9a5cTdHw-vcOn3OtQrS4c,1540
58
58
  airbyte_cdk/sources/declarative/auth/token.py,sha256=r4u3WXyVa7WmiSZ9-eZXlrUI-pS0D4YWJnwjLzwV-Fk,11210
59
59
  airbyte_cdk/sources/declarative/auth/token_provider.py,sha256=9oq3dcBPAPwXSfkISjhA05dMhIzxaDQTmwOydBrnsMk,3028
@@ -66,7 +66,7 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=tSTCSmyM
66
66
  airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
67
67
  airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
68
68
  airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
69
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=IVkRHPGvhEvB2kokL8CAfrvCHpxE_b9Ox5um42br41U,135095
69
+ airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=k_al8qcF6DSsm51IsZoUI8LCOlfZE141u2Iq5WEkfiI,135419
70
70
  airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
71
71
  airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
72
72
  airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
@@ -106,12 +106,12 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
106
106
  airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
107
107
  airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
108
108
  airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
109
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=dy9CSSvW1gAoMCAXkoOxLJTRVTrcHpYFENYgLqaUOwM,95087
109
+ airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=2UabGD45tpF_5YzjpFKcQ4PiVfCvYSa7RbrUPW7M_ZQ,95465
110
110
  airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
111
111
  airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
112
112
  airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
113
113
  airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
114
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=v0Rd3V2b6AWJpQTOVlJbP58jRfNUwuhH22Q2fiA0itc,111475
114
+ airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=9hSAdPJFG_ZUkIbdBuxj_IUKARNRsRi8a7xX82UqTQ8,111726
115
115
  airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=HJ-Syp3p7RpyR_OK0X_a2kSyISfu3W-PKrRI16iY0a8,957
116
116
  airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
117
117
  airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
@@ -288,9 +288,9 @@ airbyte_cdk/sources/streams/http/http.py,sha256=JAMpiTdS9HFNOlwayWNvQdxoqs2rpW9w
288
288
  airbyte_cdk/sources/streams/http/http_client.py,sha256=tDE0ROtxjGMVphvsw8INvGMtZ97hIF-v47pZ3jIyiwc,23011
289
289
  airbyte_cdk/sources/streams/http/rate_limiting.py,sha256=IwdjrHKUnU97XO4qONgYRv4YYW51xQ8SJm4WLafXDB8,6351
290
290
  airbyte_cdk/sources/streams/http/requests_native_auth/__init__.py,sha256=RN0D3nOX1xLgwEwKWu6pkGy3XqBFzKSNZ8Lf6umU2eY,413
291
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=xX-qKbMVN-OTwNda-B6cVQqnQrNDGBnvavAcSvXK2wU,11179
291
+ airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=-GDNyqccdutOftFpqCvvk81NwkskHhDZ8QcsUKzNjRQ,11660
292
292
  airbyte_cdk/sources/streams/http/requests_native_auth/abstract_token.py,sha256=Y3n7J-sk5yGjv_OxtY6Z6k0PEsFZmtIRi-x0KCbaHdA,1010
293
- airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py,sha256=wjsp4Xf8u3AnY7ZmTTGfLnfj6ztDBogR5biURkqcwCA,16156
293
+ airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py,sha256=OCNokL0GypjN8PUVJk1UFJVE5THkHAbNDmB984_F7W0,16718
294
294
  airbyte_cdk/sources/streams/http/requests_native_auth/token.py,sha256=h5PTzcdH-RQLeCg7xZ45w_484OPUDSwNWl_iMJQmZoI,2526
295
295
  airbyte_cdk/sources/streams/utils/__init__.py,sha256=4Hw-PX1-VgESLF16cDdvuYCzGJtHntThLF4qIiULWeo,61
296
296
  airbyte_cdk/sources/types.py,sha256=nLPkTpyfGV4E6e99qcBWX4r8C3fE4I8Fvgx2EjvT9ic,5005
@@ -343,8 +343,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
343
343
  airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
344
344
  airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
345
345
  airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
346
- airbyte_cdk-6.19.0.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
347
- airbyte_cdk-6.19.0.dist-info/METADATA,sha256=QX8m8I4zsR63ujqpxXOBwVISjVjAB8YN-K5e0b_bJAQ,6000
348
- airbyte_cdk-6.19.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
349
- airbyte_cdk-6.19.0.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
350
- airbyte_cdk-6.19.0.dist-info/RECORD,,
346
+ airbyte_cdk-6.19.1.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
347
+ airbyte_cdk-6.19.1.dist-info/METADATA,sha256=vZseMtnWdaQvyzb3uh3Egn-ahu7vHW0mijR0meswMDk,6000
348
+ airbyte_cdk-6.19.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
349
+ airbyte_cdk-6.19.1.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
350
+ airbyte_cdk-6.19.1.dist-info/RECORD,,