Skip to content

Commit

Permalink
Better error handling for missing access_token since it could happen …
Browse files Browse the repository at this point in the history
…on some Idp
  • Loading branch information
VersusFacit committed Jan 15, 2025
1 parent 55f555a commit 54678b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dbt/adapters/redshift/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,18 @@ def __iam_idc_token_kwargs(credentials) -> Dict[str, Any]:

__validate_required_fields("oauth_token_identity_center", ("token_endpoint",))

token_endpoint = create_token_service_client(credentials.token_endpoint)
response = token_endpoint.handle_request()
token_service = create_token_service_client(credentials.token_endpoint)
response = token_service.handle_request()
try:
access_token = response.json()["access_token"]
except KeyError:
raise FailedToConnectError(
"access_token missing from Idp token request. Please confirm correct configuration of the token_endpoint field in profiles.yml and that your Idp can use a refresh token to obtain an OIDC-compliant access token."
)

return __iam_kwargs(credentials) | {
"credentials_provider": "IdpTokenAuthPlugin",
"token": response.json()["access_token"],
"token": access_token,
"token_type": "EXT_JWT",
}

Expand Down

0 comments on commit 54678b6

Please sign in to comment.