4
4
from bynder_sdk .client .workflow_client import WorkflowClient
5
5
from bynder_sdk .oauth2 import BynderOAuth2Session
6
6
from bynder_sdk .permanent_token import PermanentTokenSession
7
+ from oauthlib .oauth2 import BackendApplicationClient
7
8
8
9
REQUIRED_OAUTH_KWARGS = (
9
10
'client_id' , 'client_secret' , 'redirect_uri' , 'scopes' )
@@ -29,6 +30,8 @@ def __init__(self, domain, **kwargs):
29
30
f'Missing required arguments: { missing } '
30
31
)
31
32
33
+ # if client credentials use BackendApplicationClient from oauthlib, client suited for client credentials
34
+ client_credentials = BackendApplicationClient (kwargs ['client_id' ]) if kwargs ['client_credentials' ] else None
32
35
self .session = BynderOAuth2Session (
33
36
domain ,
34
37
kwargs ['client_id' ],
@@ -38,7 +41,9 @@ def __init__(self, domain, **kwargs):
38
41
'client_id' : kwargs ['client_id' ],
39
42
'client_secret' : kwargs ['client_secret' ]
40
43
},
41
- token_updater = kwargs .get ('token_saver' , (lambda _ : None ))
44
+ token_updater = kwargs .get ('token_saver' , (lambda _ : None )),
45
+ # if client is None, default to WebApplicationClient which uses authorization_code grant type
46
+ client = client_credentials
42
47
)
43
48
44
49
if kwargs .get ('token' ) is not None :
0 commit comments