Skip to content

Commit

Permalink
Report auth error. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacadil authored Jun 3, 2024
1 parent 1823224 commit 0f73c18
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tap_klaviyo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ class KlaviyoStream(RESTStream):

@property
def authenticator(self):
api_key = self.config.get("api_private_key") or self.config.get("api_key")
# auth with access token
if self.config.get("refresh_token"):
return KlaviyoAuthenticator.create_for_stream(self)
# auth with api key
elif self.config.get("api_private_key"):
api_key = f'Klaviyo-API-Key {self.config.get("api_private_key")}'
elif api_key:
api_key = f"Klaviyo-API-Key {api_key}"
return APIKeyAuthenticator.create_for_stream(
self, key="Authorization", value=api_key, location="header"
)
else:
raise FatalAPIError("No valid authentication method found")

@property
def http_headers(self) -> dict:
Expand Down

0 comments on commit 0f73c18

Please sign in to comment.