diff --git a/docs/v1/accounting/index.html b/docs/v1/accounting/index.html index 3e12ee45..c6576366 100644 --- a/docs/v1/accounting/index.html +++ b/docs/v1/accounting/index.html @@ -6339,7 +6339,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods createAccount diff --git a/docs/v1/appstore/index.html b/docs/v1/appstore/index.html index f4492341..a324971b 100644 --- a/docs/v1/appstore/index.html +++ b/docs/v1/appstore/index.html @@ -1241,7 +1241,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods getSubscription diff --git a/docs/v1/assets/index.html b/docs/v1/assets/index.html index e83b5c7a..25d79a8c 100644 --- a/docs/v1/assets/index.html +++ b/docs/v1/assets/index.html @@ -1392,7 +1392,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods createAsset diff --git a/docs/v1/files/index.html b/docs/v1/files/index.html index 63432717..7c3ccd28 100644 --- a/docs/v1/files/index.html +++ b/docs/v1/files/index.html @@ -1170,7 +1170,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods createFileAssociation diff --git a/docs/v1/finance/index.html b/docs/v1/finance/index.html index e89a63d7..2a5c942f 100644 --- a/docs/v1/finance/index.html +++ b/docs/v1/finance/index.html @@ -2737,7 +2737,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods getAccountingActivityAccountUsage diff --git a/docs/v1/payroll-au/index.html b/docs/v1/payroll-au/index.html index 401b90bb..b5a76aa7 100644 --- a/docs/v1/payroll-au/index.html +++ b/docs/v1/payroll-au/index.html @@ -3412,7 +3412,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods approveLeaveApplication diff --git a/docs/v1/payroll-nz/index.html b/docs/v1/payroll-nz/index.html index 224df375..e8cbb786 100644 --- a/docs/v1/payroll-nz/index.html +++ b/docs/v1/payroll-nz/index.html @@ -4031,7 +4031,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods approveTimesheet diff --git a/docs/v1/payroll-uk/index.html b/docs/v1/payroll-uk/index.html index a3373f4d..dc9c5ba0 100644 --- a/docs/v1/payroll-uk/index.html +++ b/docs/v1/payroll-uk/index.html @@ -3517,7 +3517,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods approveTimesheet diff --git a/docs/v1/projects/index.html b/docs/v1/projects/index.html index 813c6d00..654f17cb 100644 --- a/docs/v1/projects/index.html +++ b/docs/v1/projects/index.html @@ -1462,7 +1462,7 @@ SDK: - VSN: 6.3.0 + VSN: 6.3.1 Methods createProject diff --git a/setup.py b/setup.py index c85f5e42..fa36b006 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="6.3.0", + version="6.3.1", ) diff --git a/tests/test_api_client/test_oauth2.py b/tests/test_api_client/test_oauth2.py index dd8eb6ee..666d3605 100644 --- a/tests/test_api_client/test_oauth2.py +++ b/tests/test_api_client/test_oauth2.py @@ -151,6 +151,50 @@ 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 d6f4211d..3fe87eb5 100644 --- a/xero_python/__init__.py +++ b/xero_python/__init__.py @@ -2,4 +2,4 @@ __author__ = """Xero Developer API""" __email__ = "api@xero.com" -__version__ = "6.3.0" +__version__ = "6.3.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 962a37bf..1b64d442 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: 6.3.0 -- Package version: 6.3.0 +- Package version: 6.3.1 - Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit [https://developer.xero.com](https://developer.xero.com)