@@ -36,28 +36,46 @@ class Client:
36
36
37
37
def __init__ (
38
38
self ,
39
- credentials : dict ,
40
39
tenant_id : str ,
41
40
reports_start_date : str ,
42
41
hourly_reports : bool ,
43
42
daily_reports : bool ,
44
43
weekly_reports : bool ,
45
44
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
46
50
** kwargs : Mapping [str , Any ],
47
51
) -> None :
48
52
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
52
55
self .hourly_reports = hourly_reports
53
56
self .daily_reports = daily_reports
54
57
self .weekly_reports = weekly_reports
55
58
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 )
57
64
self .oauth : OAuthTokens = self ._get_access_token ()
58
65
self .reports_start_date = pendulum .parse (reports_start_date ).astimezone (tz = timezone .utc )
59
66
60
67
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
+
61
79
# https://github.com/BingAds/BingAds-Python-SDK/blob/e7b5a618e87a43d0a5e2c79d9aa4626e208797bd/bingads/authorization.py#L390
62
80
auth_creds = {
63
81
"client_id" : credentials ["client_id" ],
0 commit comments