Skip to content

Commit

Permalink
Merge pull request #2 from Matatika/fix/put-all-oauth-creds-under-oau…
Browse files Browse the repository at this point in the history
…th-credentials

Fix/put all oauth creds under oauth credentials
  • Loading branch information
DanielPDWalker authored Dec 6, 2021
2 parents b7eecf4 + 086a3c7 commit 4d66adb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ pipx install tap-googleads

Settings required to run this tap.

- `client_id` (required)
- `client_secret` (required)
- `oauth_credentials.client_id` (required)
- `oauth_credentials.client_secret` (required)
- `oauth_credentials.refresh_token` (required)
- `developer_token` (required)
- `refresh_token` (required)
- `customer_id` (required)
- `start_date` (optional)
- `end_date` (optional)
Expand Down
7 changes: 0 additions & 7 deletions meltano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ plugins:
- catalog
- discover
settings:
- name: client_id
kind: password
- name: client_secret
kind: password
- name: developer_token
kind: password
- name: refresh_token
kind: password
- name: customer_id
kind: password
- name: start_date
Expand Down Expand Up @@ -50,7 +44,6 @@ plugins:
- OAUTH_CREDENTIALS_ACCESS_TOKEN
kind: hidden
label: Optional - OAuth Access Token for use with a proxy refresh server
required: false
- name: oauth_credentials.refresh_token
env_aliases:
- OAUTH_CREDENTIALS_REFRESH_TOKEN
Expand Down
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 = "tap-googleads"
version = "0.1.0"
version = "0.1.1"
description = "`tap-googleads` is a Singer tap for GoogleAds, built with the Meltano SDK for Singer Taps."
authors = ["AutoIDM", "Matatika"]
keywords = [
Expand Down
21 changes: 14 additions & 7 deletions tap_googleads/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,25 @@ def authenticator(self) -> OAuthAuthenticator:
"""Return a new authenticator object."""
base_auth_url = "https://www.googleapis.com/oauth2/v4/token"
# Silly way to do parameters but it works
auth_url = (
base_auth_url + f"?refresh_token={self.config.get('refresh_token', None)}"

client_id = self.config.get("oauth_credentials", {}).get("client_id", None)
client_secret = self.config.get("oauth_credentials", {}).get(
"client_secret", None
)
refresh_token = self.config.get("oauth_credentials", {}).get(
"refresh_token", None
)
auth_url = auth_url + f"&client_id={self.config.get('client_id')}"
auth_url = auth_url + f"&client_secret={self.config.get('client_secret')}"
auth_url = auth_url + "&grant_type=refresh_token"

oauth_credentials = self.config.get("oauth_credentials", {})
auth_url = base_auth_url + f"?refresh_token={refresh_token}"
auth_url = auth_url + f"&client_id={client_id}"
auth_url = auth_url + f"&client_secret={client_secret}"
auth_url = auth_url + "&grant_type=refresh_token"

if not oauth_credentials:
if client_id and client_secret and refresh_token:
return GoogleAdsAuthenticator(stream=self, auth_endpoint=auth_url)

oauth_credentials = self.config.get("oauth_credentials", {})

auth_body = {}
auth_headers = {}

Expand Down
6 changes: 3 additions & 3 deletions tap_googleads/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class TapGoogleAds(Tap):
# TODO: Add Descriptions
config_jsonschema = th.PropertiesList(
th.Property(
"client_id",
"oauth_credentials.client_id",
th.StringType,
),
th.Property(
"client_secret",
"oauth_credentials.client_secret",
th.StringType,
),
th.Property(
"developer_token",
th.StringType,
),
th.Property(
"refresh_token",
"oauth_credentials.refresh_token",
th.StringType,
),
th.Property(
Expand Down

0 comments on commit 4d66adb

Please sign in to comment.