Skip to content

Commit f53386b

Browse files
committed
added old config support
1 parent 6b442db commit f53386b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

airbyte-integrations/connectors/source-bing-ads/acceptance-test-config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ tests:
33
spec:
44
- spec_path: "source_bing_ads/spec.json"
55
connection:
6+
- config_path: "secrets/config_old.json"
7+
status: "succeed"
68
- config_path: "secrets/config.json"
79
status: "succeed"
810
- config_path: "integration_tests/invalid_config.json"

airbyte-integrations/connectors/source-bing-ads/source_bing_ads/client.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,46 @@ class Client:
3636

3737
def __init__(
3838
self,
39-
credentials: dict,
4039
tenant_id: str,
4140
reports_start_date: str,
4241
hourly_reports: bool,
4342
daily_reports: bool,
4443
weekly_reports: bool,
4544
monthly_reports: bool,
45+
credentials: dict = None,
46+
client_id: str = None, # deprecated
47+
client_secret: str = None, # deprecated
48+
developer_token: str = None, # deprecated
49+
refresh_token: str = None, # deprecated
4650
**kwargs: Mapping[str, Any],
4751
) -> None:
4852
self.authorization_data: Mapping[str, AuthorizationData] = {}
49-
self.authentication = self._get_auth_client(credentials, tenant_id)
50-
self.refresh_token = credentials["refresh_token"]
51-
self.developer_token = credentials["developer_token"]
53+
self.refresh_token = credentials["refresh_token"] if credentials else refresh_token
54+
self.developer_token = credentials["developer_token"] if credentials else developer_token
5255
self.hourly_reports = hourly_reports
5356
self.daily_reports = daily_reports
5457
self.weekly_reports = weekly_reports
5558
self.monthly_reports = monthly_reports
56-
59+
60+
self.client_id = client_id # deprecated
61+
self.client_secret = client_secret # deprecated
62+
63+
self.authentication = self._get_auth_client(credentials, tenant_id)
5764
self.oauth: OAuthTokens = self._get_access_token()
5865
self.reports_start_date = pendulum.parse(reports_start_date).astimezone(tz=timezone.utc)
5966

6067
def _get_auth_client(self, credentials: dict, tenant_id: str) -> OAuthWebAuthCodeGrant:
68+
69+
# support the deprecated old input configuration
70+
if self.client_id or self.client_secret:
71+
auth_creds = {
72+
"client_id": self.client_id,
73+
"client_secret": self.client_secret,
74+
"redirection_uri": "", # should be empty string
75+
"tenant": tenant_id,
76+
}
77+
return OAuthWebAuthCodeGrant(**auth_creds)
78+
6179
# https://github.com/BingAds/BingAds-Python-SDK/blob/e7b5a618e87a43d0a5e2c79d9aa4626e208797bd/bingads/authorization.py#L390
6280
auth_creds = {
6381
"client_id": credentials["client_id"],

airbyte-integrations/connectors/source-bing-ads/source_bing_ads/spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"title": "Bing Ads Spec",
66
"type": "object",
77
"required": [
8-
"credentials",
98
"reports_start_date",
109
"hourly_reports",
1110
"daily_reports",

0 commit comments

Comments
 (0)