airbyte-cdk 6.12.2__py3-none-any.whl → 6.12.3__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.
- airbyte_cdk/sources/declarative/auth/oauth.py +27 -12
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +6 -1
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +8 -2
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +3 -1
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +12 -3
- {airbyte_cdk-6.12.2.dist-info → airbyte_cdk-6.12.3.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.12.2.dist-info → airbyte_cdk-6.12.3.dist-info}/RECORD +10 -10
- {airbyte_cdk-6.12.2.dist-info → airbyte_cdk-6.12.3.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.12.2.dist-info → airbyte_cdk-6.12.3.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.12.2.dist-info → airbyte_cdk-6.12.3.dist-info}/entry_points.txt +0 -0
@@ -43,11 +43,11 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
|
|
43
43
|
message_repository (MessageRepository): the message repository used to emit logs on HTTP requests
|
44
44
|
"""
|
45
45
|
|
46
|
-
token_refresh_endpoint: Union[InterpolatedString, str]
|
47
46
|
client_id: Union[InterpolatedString, str]
|
48
47
|
client_secret: Union[InterpolatedString, str]
|
49
48
|
config: Mapping[str, Any]
|
50
49
|
parameters: InitVar[Mapping[str, Any]]
|
50
|
+
token_refresh_endpoint: Optional[Union[InterpolatedString, str]] = None
|
51
51
|
refresh_token: Optional[Union[InterpolatedString, str]] = None
|
52
52
|
scopes: Optional[List[str]] = None
|
53
53
|
token_expiry_date: Optional[Union[InterpolatedString, str]] = None
|
@@ -55,6 +55,7 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
|
|
55
55
|
token_expiry_date_format: Optional[str] = None
|
56
56
|
token_expiry_is_time_of_expiration: bool = False
|
57
57
|
access_token_name: Union[InterpolatedString, str] = "access_token"
|
58
|
+
access_token_value: Optional[Union[InterpolatedString, str]] = None
|
58
59
|
expires_in_name: Union[InterpolatedString, str] = "expires_in"
|
59
60
|
refresh_request_body: Optional[Mapping[str, Any]] = None
|
60
61
|
grant_type: Union[InterpolatedString, str] = "refresh_token"
|
@@ -62,9 +63,12 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
|
|
62
63
|
|
63
64
|
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
64
65
|
super().__init__()
|
65
|
-
self.
|
66
|
-
self.
|
67
|
-
|
66
|
+
if self.token_refresh_endpoint is not None:
|
67
|
+
self._token_refresh_endpoint: Optional[InterpolatedString] = InterpolatedString.create(
|
68
|
+
self.token_refresh_endpoint, parameters=parameters
|
69
|
+
)
|
70
|
+
else:
|
71
|
+
self._token_refresh_endpoint = None
|
68
72
|
self._client_id = InterpolatedString.create(self.client_id, parameters=parameters)
|
69
73
|
self._client_secret = InterpolatedString.create(self.client_secret, parameters=parameters)
|
70
74
|
if self.refresh_token is not None:
|
@@ -92,20 +96,31 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
|
|
92
96
|
if self.token_expiry_date
|
93
97
|
else pendulum.now().subtract(days=1) # type: ignore # substract does not have type hints
|
94
98
|
)
|
95
|
-
self.
|
99
|
+
if self.access_token_value is not None:
|
100
|
+
self._access_token_value = InterpolatedString.create(
|
101
|
+
self.access_token_value, parameters=parameters
|
102
|
+
).eval(self.config)
|
103
|
+
else:
|
104
|
+
self._access_token_value = None
|
105
|
+
|
106
|
+
self._access_token: Optional[str] = (
|
107
|
+
self._access_token_value if self.access_token_value else None
|
108
|
+
)
|
96
109
|
|
97
110
|
if self.get_grant_type() == "refresh_token" and self._refresh_token is None:
|
98
111
|
raise ValueError(
|
99
112
|
"OAuthAuthenticator needs a refresh_token parameter if grant_type is set to `refresh_token`"
|
100
113
|
)
|
101
114
|
|
102
|
-
def get_token_refresh_endpoint(self) -> str:
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
115
|
+
def get_token_refresh_endpoint(self) -> Optional[str]:
|
116
|
+
if self._token_refresh_endpoint is not None:
|
117
|
+
refresh_token_endpoint: str = self._token_refresh_endpoint.eval(self.config)
|
118
|
+
if not refresh_token_endpoint:
|
119
|
+
raise ValueError(
|
120
|
+
"OAuthAuthenticator was unable to evaluate token_refresh_endpoint parameter"
|
121
|
+
)
|
122
|
+
return refresh_token_endpoint
|
123
|
+
return None
|
109
124
|
|
110
125
|
def get_client_id(self) -> str:
|
111
126
|
client_id: str = self._client_id.eval(self.config)
|
@@ -1021,7 +1021,6 @@ definitions:
|
|
1021
1021
|
- type
|
1022
1022
|
- client_id
|
1023
1023
|
- client_secret
|
1024
|
-
- token_refresh_endpoint
|
1025
1024
|
properties:
|
1026
1025
|
type:
|
1027
1026
|
type: string
|
@@ -1060,6 +1059,12 @@ definitions:
|
|
1060
1059
|
default: "access_token"
|
1061
1060
|
examples:
|
1062
1061
|
- access_token
|
1062
|
+
access_token_value:
|
1063
|
+
title: Access Token Value
|
1064
|
+
description: The value of the access_token to bypass the token refreshing using `refresh_token`.
|
1065
|
+
type: string
|
1066
|
+
examples:
|
1067
|
+
- secret_access_token_value
|
1063
1068
|
expires_in_name:
|
1064
1069
|
title: Token Expiry Property Name
|
1065
1070
|
description: The name of the property which contains the expiry date in the response from the token refresh endpoint.
|
@@ -489,8 +489,8 @@ class OAuthAuthenticator(BaseModel):
|
|
489
489
|
],
|
490
490
|
title="Refresh Token",
|
491
491
|
)
|
492
|
-
token_refresh_endpoint: str = Field(
|
493
|
-
|
492
|
+
token_refresh_endpoint: Optional[str] = Field(
|
493
|
+
None,
|
494
494
|
description="The full URL to call to obtain a new access token.",
|
495
495
|
examples=["https://connect.squareup.com/oauth2/token"],
|
496
496
|
title="Token Refresh Endpoint",
|
@@ -501,6 +501,12 @@ class OAuthAuthenticator(BaseModel):
|
|
501
501
|
examples=["access_token"],
|
502
502
|
title="Access Token Property Name",
|
503
503
|
)
|
504
|
+
access_token_value: Optional[str] = Field(
|
505
|
+
None,
|
506
|
+
description="The value of the access_token to bypass the token refreshing using `refresh_token`.",
|
507
|
+
examples=["secret_access_token_value"],
|
508
|
+
title="Access Token Value",
|
509
|
+
)
|
504
510
|
expires_in_name: Optional[str] = Field(
|
505
511
|
"expires_in",
|
506
512
|
description="The name of the property which contains the expiry date in the response from the token refresh endpoint.",
|
@@ -1800,7 +1800,8 @@ class ModelToComponentFactory:
|
|
1800
1800
|
return DeclarativeSingleUseRefreshTokenOauth2Authenticator( # type: ignore
|
1801
1801
|
config,
|
1802
1802
|
InterpolatedString.create(
|
1803
|
-
model.token_refresh_endpoint,
|
1803
|
+
model.token_refresh_endpoint, # type: ignore
|
1804
|
+
parameters=model.parameters or {},
|
1804
1805
|
).eval(config),
|
1805
1806
|
access_token_name=InterpolatedString.create(
|
1806
1807
|
model.access_token_name or "access_token", parameters=model.parameters or {}
|
@@ -1834,6 +1835,7 @@ class ModelToComponentFactory:
|
|
1834
1835
|
# ignore type error because fixing it would have a lot of dependencies, revisit later
|
1835
1836
|
return DeclarativeOauth2Authenticator( # type: ignore
|
1836
1837
|
access_token_name=model.access_token_name or "access_token",
|
1838
|
+
access_token_value=model.access_token_value,
|
1837
1839
|
client_id=model.client_id,
|
1838
1840
|
client_secret=model.client_secret,
|
1839
1841
|
expires_in_name=model.expires_in_name or "expires_in",
|
@@ -54,7 +54,16 @@ class AbstractOauth2Authenticator(AuthBase):
|
|
54
54
|
|
55
55
|
def get_auth_header(self) -> Mapping[str, Any]:
|
56
56
|
"""HTTP header to set on the requests"""
|
57
|
-
|
57
|
+
token = (
|
58
|
+
self.access_token
|
59
|
+
if (
|
60
|
+
not self.get_token_refresh_endpoint()
|
61
|
+
or not self.get_refresh_token()
|
62
|
+
and self.access_token
|
63
|
+
)
|
64
|
+
else self.get_access_token()
|
65
|
+
)
|
66
|
+
return {"Authorization": f"Bearer {token}"}
|
58
67
|
|
59
68
|
def get_access_token(self) -> str:
|
60
69
|
"""Returns the access token"""
|
@@ -121,7 +130,7 @@ class AbstractOauth2Authenticator(AuthBase):
|
|
121
130
|
try:
|
122
131
|
response = requests.request(
|
123
132
|
method="POST",
|
124
|
-
url=self.get_token_refresh_endpoint(),
|
133
|
+
url=self.get_token_refresh_endpoint(), # type: ignore # returns None, if not provided, but str | bytes is expected.
|
125
134
|
data=self.build_refresh_request_body(),
|
126
135
|
)
|
127
136
|
if response.ok:
|
@@ -198,7 +207,7 @@ class AbstractOauth2Authenticator(AuthBase):
|
|
198
207
|
return None
|
199
208
|
|
200
209
|
@abstractmethod
|
201
|
-
def get_token_refresh_endpoint(self) -> str:
|
210
|
+
def get_token_refresh_endpoint(self) -> Optional[str]:
|
202
211
|
"""Returns the endpoint to refresh the access token"""
|
203
212
|
|
204
213
|
@abstractmethod
|
@@ -53,7 +53,7 @@ airbyte_cdk/sources/declarative/async_job/timer.py,sha256=Fb8P72CQ7jIzJyzMSSNuBf
|
|
53
53
|
airbyte_cdk/sources/declarative/auth/__init__.py,sha256=hhiJV3kU5_fja7hQYWqbYjjtJPpaJdS2NiJpJLrG2uw,294
|
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=
|
56
|
+
airbyte_cdk/sources/declarative/auth/oauth.py,sha256=Yr0ljFjln9FIWudQohXARyKEo6-4ACG840pZoi6JVrE,9165
|
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=PxP4p268
|
|
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=
|
69
|
+
airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=11mRmSliG_WNgMNoLSwTuwtV8-ebT7ar2vaMJH-6SCI,129628
|
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=hNlhaB5FjNC6IfJyglj5ZJWkYD2nEAukMDmzRz5PC6o,671
|
@@ -104,12 +104,12 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
|
|
104
104
|
airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
|
105
105
|
airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
|
106
106
|
airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
|
107
|
-
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=
|
107
|
+
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=R52aqtbZs81CQvo9gappzLr9eu2_TJmuT7NSfMDdhXI,91100
|
108
108
|
airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
|
109
109
|
airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
|
110
110
|
airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
|
111
111
|
airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
|
112
|
-
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256
|
112
|
+
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=aSJwsGHHjRUGbQNgqf53fVkZ-3PsTeIEcvzTw-s-KP0,106161
|
113
113
|
airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=974SY1RFwitUCiiDHuFHDGmSNu1D72z3bSTpvlBwAho,911
|
114
114
|
airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=n82J15S8bjeMZ5uROu--P3hnbQoxkY5v7RPHYx7g7ro,2929
|
115
115
|
airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
|
@@ -284,7 +284,7 @@ airbyte_cdk/sources/streams/http/http.py,sha256=JAMpiTdS9HFNOlwayWNvQdxoqs2rpW9w
|
|
284
284
|
airbyte_cdk/sources/streams/http/http_client.py,sha256=tDE0ROtxjGMVphvsw8INvGMtZ97hIF-v47pZ3jIyiwc,23011
|
285
285
|
airbyte_cdk/sources/streams/http/rate_limiting.py,sha256=IwdjrHKUnU97XO4qONgYRv4YYW51xQ8SJm4WLafXDB8,6351
|
286
286
|
airbyte_cdk/sources/streams/http/requests_native_auth/__init__.py,sha256=RN0D3nOX1xLgwEwKWu6pkGy3XqBFzKSNZ8Lf6umU2eY,413
|
287
|
-
airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=
|
287
|
+
airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py,sha256=fnxafAc8qBFWVN_r7ViOWqDObfe3S_DWhnlNfabMWSI,10661
|
288
288
|
airbyte_cdk/sources/streams/http/requests_native_auth/abstract_token.py,sha256=Y3n7J-sk5yGjv_OxtY6Z6k0PEsFZmtIRi-x0KCbaHdA,1010
|
289
289
|
airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py,sha256=ka-bBRWvIv09LmZNYl49p2lK9nd_Tvi2g0lIp3OkU40,14872
|
290
290
|
airbyte_cdk/sources/streams/http/requests_native_auth/token.py,sha256=h5PTzcdH-RQLeCg7xZ45w_484OPUDSwNWl_iMJQmZoI,2526
|
@@ -339,8 +339,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
|
|
339
339
|
airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
|
340
340
|
airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
|
341
341
|
airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
|
342
|
-
airbyte_cdk-6.12.
|
343
|
-
airbyte_cdk-6.12.
|
344
|
-
airbyte_cdk-6.12.
|
345
|
-
airbyte_cdk-6.12.
|
346
|
-
airbyte_cdk-6.12.
|
342
|
+
airbyte_cdk-6.12.3.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
343
|
+
airbyte_cdk-6.12.3.dist-info/METADATA,sha256=DdnFFX5s5OryiCi_NdkLKY0kaS73iI-GmSTbJuX-nVI,5988
|
344
|
+
airbyte_cdk-6.12.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
345
|
+
airbyte_cdk-6.12.3.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
|
346
|
+
airbyte_cdk-6.12.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|