Skip to content

Commit

Permalink
add support for api key in url
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Feb 6, 2024
1 parent 2791842 commit c77c509
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "target-api"
version = "0.0.2"
version = "0.0.10"
description = "`target-api` is a Singer target for Api, built with the Meltano Singer SDK."
readme = "README.md"
authors = ["Davi Souza"]
Expand Down
9 changes: 7 additions & 2 deletions target_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def authenticator(self):
self._target,
header_name=self._config.get("api_key_header") or "x-api-key",
)
if self._config.get("auth", False)
if self._config.get("auth", False) or self._config.get("api_key_url")
else None
)

Expand All @@ -32,7 +32,7 @@ def base_url(self) -> str:
tap = os.environ.get('TAP', None)
connector_id = os.environ.get('CONNECTOR_ID', None)

return self._config["url"].format(
base_url = self._config["url"].format(
stream=self.stream_name,
tenant=tenant_id,
tenant_id=tenant_id,
Expand All @@ -42,6 +42,11 @@ def base_url(self) -> str:
connector_id=connector_id
)

if self._config.get("api_key_url"):
base_url += f"?{self._config.get('api_key_header')}={self._config.get('api_key')}"

return base_url

@property
def endpoint(self) -> str:
return ""
Expand Down

0 comments on commit c77c509

Please sign in to comment.