diff --git a/docs/v1/accounting/index.html b/docs/v1/accounting/index.html index 2688b484..fe71624d 100644 --- a/docs/v1/accounting/index.html +++ b/docs/v1/accounting/index.html @@ -6339,7 +6339,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods createAccount diff --git a/docs/v1/appstore/index.html b/docs/v1/appstore/index.html index 1f4eb9ac..01fdfa5c 100644 --- a/docs/v1/appstore/index.html +++ b/docs/v1/appstore/index.html @@ -1241,7 +1241,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods getSubscription diff --git a/docs/v1/assets/index.html b/docs/v1/assets/index.html index a16e71e9..017c355c 100644 --- a/docs/v1/assets/index.html +++ b/docs/v1/assets/index.html @@ -1392,7 +1392,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods createAsset diff --git a/docs/v1/files/index.html b/docs/v1/files/index.html index 558eb317..135548e9 100644 --- a/docs/v1/files/index.html +++ b/docs/v1/files/index.html @@ -1170,7 +1170,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods createFileAssociation diff --git a/docs/v1/finance/index.html b/docs/v1/finance/index.html index 1c417778..12d3c887 100644 --- a/docs/v1/finance/index.html +++ b/docs/v1/finance/index.html @@ -2716,7 +2716,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods getAccountingActivityAccountUsage diff --git a/docs/v1/payroll-au/index.html b/docs/v1/payroll-au/index.html index 09f0135b..32e69e0c 100644 --- a/docs/v1/payroll-au/index.html +++ b/docs/v1/payroll-au/index.html @@ -3412,7 +3412,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods approveLeaveApplication diff --git a/docs/v1/payroll-nz/index.html b/docs/v1/payroll-nz/index.html index b8cb75b7..39745dcb 100644 --- a/docs/v1/payroll-nz/index.html +++ b/docs/v1/payroll-nz/index.html @@ -4087,7 +4087,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods approveTimesheet diff --git a/docs/v1/payroll-uk/index.html b/docs/v1/payroll-uk/index.html index 792b2520..7a6c91d4 100644 --- a/docs/v1/payroll-uk/index.html +++ b/docs/v1/payroll-uk/index.html @@ -3517,7 +3517,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods approveTimesheet diff --git a/docs/v1/projects/index.html b/docs/v1/projects/index.html index fb6d5040..2ea5c61c 100644 --- a/docs/v1/projects/index.html +++ b/docs/v1/projects/index.html @@ -1462,7 +1462,7 @@ SDK: - VSN: 7.0.0 + VSN: 7.0.1 Methods createProject diff --git a/setup.py b/setup.py index 7a45268c..ea787609 100644 --- a/setup.py +++ b/setup.py @@ -48,5 +48,5 @@ def read_file(filename): keywords="xero python sdk API oAuth", name="xero_python", packages=find_packages(include=["xero_python", "xero_python.*"]), - version="7.0.0", + version="7.0.1", ) diff --git a/tests/test_api_client/test_oauth2.py b/tests/test_api_client/test_oauth2.py index dd8eb6ee..cc2eb2c1 100644 --- a/tests/test_api_client/test_oauth2.py +++ b/tests/test_api_client/test_oauth2.py @@ -151,6 +151,49 @@ def test_auth2_refresh_access_token(): assert oauth2_token.access_token == new_token["access_token"] assert oauth2_token.refresh_token == new_token["refresh_token"] +def test_auth2_refresh_access_token_having_scope_as_string(): + # given OAuth2Token with expired access_token + api_client = FakeClass() + api_client.set_oauth2_token = FakeMethod() + refresh_token = "refresh-token-value" + scope = ( + "email profile openid accounting.reports.read " + "accounting.attachments.read accounting.settings " + "accounting.settings.read accounting.attachments " + "accounting.transactions accounting.journals.read " + "accounting.transactions.read accounting.contacts " + "accounting.contacts.read offline_access" + ) + new_token = { + "id_token": "new-id-token-value", + "access_token": "new-access-token-value", + "expires_in": 1800, + "expires_at": time.time() + 1800, + "token_type": "Bearer", + "refresh_token": "new-refresh-token-value", + "scope": scope, + } + oauth2_token = OAuth2Token(client_id="client_id", client_secret="client_secret") + oauth2_token.refresh_token = refresh_token + oauth2_token.scope = scope + oauth2_token.fetch_access_token = FakeMethod(return_value=new_token) + # When refreshing access_token + assert oauth2_token.refresh_access_token(api_client=api_client) + # Then expected set new token function called + assert len(oauth2_token.fetch_access_token.calls) == 1 + assert len(api_client.set_oauth2_token.calls) == 1 + call_args, call_kwargs = api_client.set_oauth2_token.calls[0] + assert call_args == (new_token,) + assert call_kwargs == {} + # Then expected new valid access and refresh tokens set on oauth2_token + assert oauth2_token.expires_at == new_token["expires_at"] + assert oauth2_token.is_access_token_valid() + assert oauth2_token.id_token == new_token["id_token"] + assert oauth2_token.expires_in == new_token["expires_in"] + assert oauth2_token.token_type == new_token["token_type"] + assert oauth2_token.scope == new_token["scope"] + assert oauth2_token.access_token == new_token["access_token"] + assert oauth2_token.refresh_token == new_token["refresh_token"] def test_auth2_fetch_access_token(): # Given OAuth2Token with valid refresh_token diff --git a/xero_python/__init__.py b/xero_python/__init__.py index ffe4266a..36aa66ac 100644 --- a/xero_python/__init__.py +++ b/xero_python/__init__.py @@ -2,4 +2,4 @@ __author__ = """Xero Developer API""" __email__ = "api@xero.com" -__version__ = "7.0.0" +__version__ = "7.0.1" diff --git a/xero_python/api_client/oauth2.py b/xero_python/api_client/oauth2.py index ca7aab20..f2277425 100644 --- a/xero_python/api_client/oauth2.py +++ b/xero_python/api_client/oauth2.py @@ -213,7 +213,7 @@ def can_refresh_access_token(self): """ return ( self.refresh_token - and isinstance(self.scope, (list, tuple)) + and isinstance(self.scope, (list, tuple, str)) and self.client_id and self.client_secret ) diff --git a/xero_python/docs/README.md b/xero_python/docs/README.md index f82f9b4a..eafa6285 100644 --- a/xero_python/docs/README.md +++ b/xero_python/docs/README.md @@ -4,7 +4,7 @@ These endpoints are related to managing authentication tokens and identity for X The `xero_python` package is automatically generated by the [XeroAPI SDK 2.0 Codegen](https://github.com/xero-github/xeroapi-sdk-codegen) project: - API version: 7.0.0 -- Package version: 7.0.0 +- Package version: 7.0.1 - Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit [https://developer.xero.com](https://developer.xero.com)