Skip to content

Commit 176401b

Browse files
committed
estuary-cdk: add default value to token_type.
This default is needed for authentication endpoints that do not return a `token_type` in their response.
1 parent 691342d commit 176401b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

estuary-cdk/estuary_cdk/http.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ async def _request_stream(
255255
class TokenSource:
256256
class AccessTokenResponse(BaseModel):
257257
access_token: str
258-
token_type: str
258+
token_type: str = ""
259259
expires_in: int = 0
260260
refresh_token: str = ""
261261
scope: str = ""
@@ -501,12 +501,14 @@ async def _establish_connection_and_get_response(
501501
):
502502
if with_token and self.token_source is not None:
503503
token_type, token = await self.token_source.fetch_token(log, self)
504-
header_value = (
505-
f"{token_type} {token}"
506-
if self.token_source.authorization_header
507-
== DEFAULT_AUTHORIZATION_HEADER
508-
else f"{token}"
509-
)
504+
if self.token_source.authorization_header == DEFAULT_AUTHORIZATION_HEADER:
505+
if not token_type:
506+
log.warning(
507+
"using default Authorization header without a token type prefix",
508+
)
509+
header_value = f"{token_type} {token}" if token_type else token
510+
else:
511+
header_value = token
510512
headers[self.token_source.authorization_header] = header_value
511513

512514
# Only pass timeout if explicitly provided. Otherwise, omit the

0 commit comments

Comments
 (0)