p2-inc / phasetwo-python

Phase Two API Python SDK
https://phasetwo.io
Apache License 2.0
3 stars 4 forks source link

Fix missing access_token attribute in Configuration #1

Closed acidAnn closed 1 year ago

acidAnn commented 1 year ago

The attribute access_token in Configuration is needed in Configuration.auth_settings(). However, it is never set in Configuration.__init__().

This leads to an exception when you try to make an API call based on a configuration. For example, here is a call of get_webhooks in the EventsAPI:

File "...", line 53, in get_webhooks
    api_response = api_instance.get_webhooks(path_params={"realm": realm})
  File "phasetwo/paths/realm_webhooks/get.py", line 255, in get_webhooks
    return self._get_webhooks_oapg(
  File "phasetwo/paths/realm_webhooks/get.py", line 185, in _get_webhooks_oapg
    response = self.api_client.call_api(
  File "phasetwo/api_client.py", line 1137, in call_api
    return self.__call_api(
  File "phasetwo/api_client.py", line 1063, in __call_api
    self.update_params_for_auth(used_headers,
  File "phasetwo/api_client.py", line 1241, in update_params_for_auth
    auth_setting = self.configuration.auth_settings().get(auth)
  File "phasetwo/configuration.py", line 367, in auth_settings
    if self.access_token is not None:
AttributeError: 'Configuration' object has no attribute 'access_token'

This pull request adds access_token to Configuration.__init__() as an optional parameter with default None. This way, it is possible to pass access_token to Configuration so that the authentication for API calls succeeds.

xgp commented 1 year ago

Thanks for the PR!