Skip to content

Commit 1dfa29f

Browse files
committed
fix: can_refresh_access_token method accepts string as valid token type
1 parent 32ae387 commit 1dfa29f

File tree

14 files changed

+56
-13
lines changed

14 files changed

+56
-13
lines changed

Diff for: docs/v1/accounting/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6339,7 +6339,7 @@
63396339
<nav id="scrollingNav">
63406340
<ul class="sidenav nav nav-list">
63416341
<li class="nav-header" data-group="Accounting"><strong>SDK: </strong><span id='sdk-name'></span></li>
6342-
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>7.0.0</li>
6342+
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>7.0.1</li>
63436343
<li class="nav-header" data-group="Accounting"><a href="#api-Accounting">Methods</a></li>
63446344
<li data-group="Accounting" data-name="createAccount" class="">
63456345
<a href="#api-Accounting-createAccount">createAccount</a>

Diff for: docs/v1/appstore/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@
12411241
<nav id="scrollingNav">
12421242
<ul class="sidenav nav nav-list">
12431243
<li class="nav-header" data-group="AppStore"><strong>SDK: </strong><span id='sdk-name'></span></li>
1244-
<li class="nav-header" data-group="AppStore"><strong>VSN: </strong>7.0.0</li>
1244+
<li class="nav-header" data-group="AppStore"><strong>VSN: </strong>7.0.1</li>
12451245
<li class="nav-header" data-group="AppStore"><a href="#api-AppStore">Methods</a></li>
12461246
<li data-group="AppStore" data-name="getSubscription" class="">
12471247
<a href="#api-AppStore-getSubscription">getSubscription</a>

Diff for: docs/v1/assets/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@
13921392
<nav id="scrollingNav">
13931393
<ul class="sidenav nav nav-list">
13941394
<li class="nav-header" data-group="Asset"><strong>SDK: </strong><span id='sdk-name'></span></li>
1395-
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>7.0.0</li>
1395+
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>7.0.1</li>
13961396
<li class="nav-header" data-group="Asset"><a href="#api-Asset">Methods</a></li>
13971397
<li data-group="Asset" data-name="createAsset" class="">
13981398
<a href="#api-Asset-createAsset">createAsset</a>

Diff for: docs/v1/files/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@
11701170
<nav id="scrollingNav">
11711171
<ul class="sidenav nav nav-list">
11721172
<li class="nav-header" data-group="Files"><strong>SDK: </strong><span id='sdk-name'></span></li>
1173-
<li class="nav-header" data-group="Files"><strong>VSN: </strong>7.0.0</li>
1173+
<li class="nav-header" data-group="Files"><strong>VSN: </strong>7.0.1</li>
11741174
<li class="nav-header" data-group="Files"><a href="#api-Files">Methods</a></li>
11751175
<li data-group="Files" data-name="createFileAssociation" class="">
11761176
<a href="#api-Files-createFileAssociation">createFileAssociation</a>

Diff for: docs/v1/finance/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@
27162716
<nav id="scrollingNav">
27172717
<ul class="sidenav nav nav-list">
27182718
<li class="nav-header" data-group="Finance"><strong>SDK: </strong><span id='sdk-name'></span></li>
2719-
<li class="nav-header" data-group="Finance"><strong>VSN: </strong>7.0.0</li>
2719+
<li class="nav-header" data-group="Finance"><strong>VSN: </strong>7.0.1</li>
27202720
<li class="nav-header" data-group="Finance"><a href="#api-Finance">Methods</a></li>
27212721
<li data-group="Finance" data-name="getAccountingActivityAccountUsage" class="">
27222722
<a href="#api-Finance-getAccountingActivityAccountUsage">getAccountingActivityAccountUsage</a>

Diff for: docs/v1/payroll-au/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,7 @@
34123412
<nav id="scrollingNav">
34133413
<ul class="sidenav nav nav-list">
34143414
<li class="nav-header" data-group="PayrollAu"><strong>SDK: </strong><span id='sdk-name'></span></li>
3415-
<li class="nav-header" data-group="PayrollAu"><strong>VSN: </strong>7.0.0</li>
3415+
<li class="nav-header" data-group="PayrollAu"><strong>VSN: </strong>7.0.1</li>
34163416
<li class="nav-header" data-group="PayrollAu"><a href="#api-PayrollAu">Methods</a></li>
34173417
<li data-group="PayrollAu" data-name="approveLeaveApplication" class="">
34183418
<a href="#api-PayrollAu-approveLeaveApplication">approveLeaveApplication</a>

Diff for: docs/v1/payroll-nz/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4087,7 +4087,7 @@
40874087
<nav id="scrollingNav">
40884088
<ul class="sidenav nav nav-list">
40894089
<li class="nav-header" data-group="PayrollNz"><strong>SDK: </strong><span id='sdk-name'></span></li>
4090-
<li class="nav-header" data-group="PayrollNz"><strong>VSN: </strong>7.0.0</li>
4090+
<li class="nav-header" data-group="PayrollNz"><strong>VSN: </strong>7.0.1</li>
40914091
<li class="nav-header" data-group="PayrollNz"><a href="#api-PayrollNz">Methods</a></li>
40924092
<li data-group="PayrollNz" data-name="approveTimesheet" class="">
40934093
<a href="#api-PayrollNz-approveTimesheet">approveTimesheet</a>

Diff for: docs/v1/payroll-uk/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3517,7 +3517,7 @@
35173517
<nav id="scrollingNav">
35183518
<ul class="sidenav nav nav-list">
35193519
<li class="nav-header" data-group="PayrollUk"><strong>SDK: </strong><span id='sdk-name'></span></li>
3520-
<li class="nav-header" data-group="PayrollUk"><strong>VSN: </strong>7.0.0</li>
3520+
<li class="nav-header" data-group="PayrollUk"><strong>VSN: </strong>7.0.1</li>
35213521
<li class="nav-header" data-group="PayrollUk"><a href="#api-PayrollUk">Methods</a></li>
35223522
<li data-group="PayrollUk" data-name="approveTimesheet" class="">
35233523
<a href="#api-PayrollUk-approveTimesheet">approveTimesheet</a>

Diff for: docs/v1/projects/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@
14621462
<nav id="scrollingNav">
14631463
<ul class="sidenav nav nav-list">
14641464
<li class="nav-header" data-group="Project"><strong>SDK: </strong><span id='sdk-name'></span></li>
1465-
<li class="nav-header" data-group="Project"><strong>VSN: </strong>7.0.0</li>
1465+
<li class="nav-header" data-group="Project"><strong>VSN: </strong>7.0.1</li>
14661466
<li class="nav-header" data-group="Project"><a href="#api-Project">Methods</a></li>
14671467
<li data-group="Project" data-name="createProject" class="">
14681468
<a href="#api-Project-createProject">createProject</a>

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ def read_file(filename):
4848
keywords="xero python sdk API oAuth",
4949
name="xero_python",
5050
packages=find_packages(include=["xero_python", "xero_python.*"]),
51-
version="7.0.0",
51+
version="7.0.1",
5252
)

Diff for: tests/test_api_client/test_oauth2.py

+43
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,49 @@ def test_auth2_refresh_access_token():
151151
assert oauth2_token.access_token == new_token["access_token"]
152152
assert oauth2_token.refresh_token == new_token["refresh_token"]
153153

154+
def test_auth2_refresh_access_token_having_scope_as_string():
155+
# given OAuth2Token with expired access_token
156+
api_client = FakeClass()
157+
api_client.set_oauth2_token = FakeMethod()
158+
refresh_token = "refresh-token-value"
159+
scope = (
160+
"email profile openid accounting.reports.read "
161+
"accounting.attachments.read accounting.settings "
162+
"accounting.settings.read accounting.attachments "
163+
"accounting.transactions accounting.journals.read "
164+
"accounting.transactions.read accounting.contacts "
165+
"accounting.contacts.read offline_access"
166+
)
167+
new_token = {
168+
"id_token": "new-id-token-value",
169+
"access_token": "new-access-token-value",
170+
"expires_in": 1800,
171+
"expires_at": time.time() + 1800,
172+
"token_type": "Bearer",
173+
"refresh_token": "new-refresh-token-value",
174+
"scope": scope,
175+
}
176+
oauth2_token = OAuth2Token(client_id="client_id", client_secret="client_secret")
177+
oauth2_token.refresh_token = refresh_token
178+
oauth2_token.scope = scope
179+
oauth2_token.fetch_access_token = FakeMethod(return_value=new_token)
180+
# When refreshing access_token
181+
assert oauth2_token.refresh_access_token(api_client=api_client)
182+
# Then expected set new token function called
183+
assert len(oauth2_token.fetch_access_token.calls) == 1
184+
assert len(api_client.set_oauth2_token.calls) == 1
185+
call_args, call_kwargs = api_client.set_oauth2_token.calls[0]
186+
assert call_args == (new_token,)
187+
assert call_kwargs == {}
188+
# Then expected new valid access and refresh tokens set on oauth2_token
189+
assert oauth2_token.expires_at == new_token["expires_at"]
190+
assert oauth2_token.is_access_token_valid()
191+
assert oauth2_token.id_token == new_token["id_token"]
192+
assert oauth2_token.expires_in == new_token["expires_in"]
193+
assert oauth2_token.token_type == new_token["token_type"]
194+
assert oauth2_token.scope == new_token["scope"]
195+
assert oauth2_token.access_token == new_token["access_token"]
196+
assert oauth2_token.refresh_token == new_token["refresh_token"]
154197

155198
def test_auth2_fetch_access_token():
156199
# Given OAuth2Token with valid refresh_token

Diff for: xero_python/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """Xero Developer API"""
44
__email__ = "[email protected]"
5-
__version__ = "7.0.0"
5+
__version__ = "7.0.1"

Diff for: xero_python/api_client/oauth2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def can_refresh_access_token(self):
213213
"""
214214
return (
215215
self.refresh_token
216-
and isinstance(self.scope, (list, tuple))
216+
and isinstance(self.scope, (list, tuple, str))
217217
and self.client_id
218218
and self.client_secret
219219
)

Diff for: xero_python/docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ These endpoints are related to managing authentication tokens and identity for X
44
The `xero_python` package is automatically generated by the [XeroAPI SDK 2.0 Codegen](https://github.com/xero-github/xeroapi-sdk-codegen) project:
55

66
- API version: 7.0.0
7-
- Package version: 7.0.0
7+
- Package version: 7.0.1
88
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
99
For more information, please visit [https://developer.xero.com](https://developer.xero.com)
1010

0 commit comments

Comments
 (0)