diff --git a/Makefile b/Makefile index 2b9b007..7b4ae17 100644 --- a/Makefile +++ b/Makefile @@ -48,4 +48,8 @@ run-docker: .PHONY: stop-docker stop-docker: - docker-compose down \ No newline at end of file + docker-compose down + +.PHONY: update-container-package +update-container-package: + docker-compose exec bynder-python-sdk sh -c "pip install -e ." \ No newline at end of file diff --git a/README.md b/README.md index 0dd600f..5d49224 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,13 @@ All sample files are located in the `./samples` directory. > :warning: Caution: The sample scripts are provided as examples. It is crucial to review, add and/or modify the commands before execution. The container updates automatically with changes, ensuring a seamless development experience. Always exercise caution when executing scripts. +Update the package within container to reflect local changes by running + +```bash +make update-container-package +``` +This will run `pip install -e .` inside the container to use local package changes. + ## Stopping the Docker Container When you're done with your development or testing, you can stop the Docker container using the following command: diff --git a/bynder_sdk/client/bynder_client.py b/bynder_sdk/client/bynder_client.py index 4d73bae..ecb1e8c 100644 --- a/bynder_sdk/client/bynder_client.py +++ b/bynder_sdk/client/bynder_client.py @@ -9,6 +9,8 @@ REQUIRED_OAUTH_KWARGS = ( 'client_id', 'client_secret', 'redirect_uri', 'scopes') +REQUIRED_OAUTH_KWARGS_CLIENT_CREDENTIALS = ('client_id', 'client_secret') + class BynderClient: """ Main client used for setting up the OAuth2 session and @@ -21,22 +23,29 @@ def __init__(self, domain, **kwargs): self.session = PermanentTokenSession( domain, kwargs['permanent_token']) else: - missing = [ - kw for kw in REQUIRED_OAUTH_KWARGS - if kwargs.get(kw) is None - ] + if kwargs.get('client_credentials', None): + missing = [ + kw for kw in REQUIRED_OAUTH_KWARGS_CLIENT_CREDENTIALS + if kwargs.get(kw) is None + ] + else: + missing = [ + kw for kw in REQUIRED_OAUTH_KWARGS + if kwargs.get(kw) is None + ] + if missing: raise TypeError( f'Missing required arguments: {missing}' ) # if client credentials use BackendApplicationClient from oauthlib, client suited for client credentials - client_credentials = BackendApplicationClient(kwargs['client_id']) if kwargs.get('client_credentials', None) == True else None + client_credentials = BackendApplicationClient(kwargs['client_id']) if kwargs.get('client_credentials', None) else None self.session = BynderOAuth2Session( domain, kwargs['client_id'], - scope=kwargs['scopes'], - redirect_uri=kwargs['redirect_uri'], + scope=kwargs['scopes'] if kwargs.get('scopes', None) else None, + redirect_uri=kwargs['redirect_uri'] if kwargs.get('redirect_uri', None) else None, auto_refresh_kwargs={ 'client_id': kwargs['client_id'], 'client_secret': kwargs['client_secret']