Skip to content

Commit f77cb41

Browse files
authored
Merge pull request #217 from box/1.5_jwt_token_refresh_fix
Fix JWT Token Refresh and bump version to 1.5.4 Fixes #197 in v1.5. Pull in repo config changes from master branch. Add testing support for Python 3.6, and upgrade PyPy tests to use PyPy2.7 5.8.0. Lock sphinx to a version that still supports Python 2.6. (In the future, on the master branch, we should exclude the sphinx install from CI jobs that don't use it, and use Python 3.6 for the job that does require sphinx.) Add new pattern to .gitignore, update configs in .pylintrc, add isort config. Add versioning note to README. Cherry pick Python3.6 support from master branch. Bump version to 1.5.4
2 parents a1dba2d + 89effbb commit f77cb41

File tree

21 files changed

+231
-49
lines changed

21 files changed

+231
-49
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ __pycache__/
1111
# Distribution / packaging
1212
bin/
1313
.Python
14-
env/
14+
env*/
1515
build/
1616
develop-eggs/
1717
dist/
@@ -27,8 +27,10 @@ var/
2727
*.egg
2828
MANIFEST
2929
.eggs/
30+
.env*/
3031
.pyenv/
31-
.venv/
32+
venv*/
33+
.venv*/
3234

3335
# PyInstaller
3436
# Usually these files are written by a python script from a template

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ defining-attr-methods=__init__,__new__,setUp
201201
valid-classmethod-first-arg=cls
202202

203203
# List of valid names for the first argument in a metaclass class method.
204-
valid-metaclass-classmethod-first-arg=mcs
204+
valid-metaclass-classmethod-first-arg=mcs,metacls
205205

206206

207207
[DESIGN]
@@ -226,7 +226,7 @@ max-branches=12
226226
max-statements=50
227227

228228
# Maximum number of parents for a class (see R0901).
229-
max-parents=7
229+
max-parents=14
230230

231231
# Maximum number of attributes for a class (see R0902).
232232
max-attributes=15

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ matrix:
2020
env: TOX_ENV=py34
2121
- python: 3.5
2222
env: TOX_ENV=py35
23+
- python: 3.6
24+
env: TOX_ENV=py36
2325
- python: pypy
24-
env: TOX_ENV=pypy PYPY_VERSION='4.0.0'
26+
env: TOX_ENV=pypy PYPY_VERSION='2.7-5.8.0'
2527
- python: 2.7
2628
env: TOX_ENV=pep8
2729
- python: 2.7

.travis/install.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
4141
pyenv install 3.5.0
4242
pyenv global 3.5.0
4343
;;
44+
py36)
45+
pyenv install 3.6.0
46+
pyenv global 3.6.0
47+
;;
4448
pypy)
45-
pyenv install "pypy-${PYPY_VERSION}"
46-
pyenv global "pypy-${PYPY_VERSION}"
49+
pyenv install "pypy${PYPY_VERSION}"
50+
pyenv global "pypy${PYPY_VERSION}"
4751
;;
4852
esac
4953
pyenv rehash
@@ -55,8 +59,8 @@ else
5559
export PYENV_ROOT="$PWD/.pyenv"
5660
export PATH="$PYENV_ROOT/bin:$PATH"
5761
eval "$(pyenv init -)"
58-
pyenv install "pypy-${PYPY_VERSION}"
59-
pyenv global "pypy-${PYPY_VERSION}"
62+
pyenv install "pypy${PYPY_VERSION}"
63+
pyenv global "pypy${PYPY_VERSION}"
6064
fi
6165
pip install -U virtualenv
6266
fi

.travis/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ else
1414
export PYENV_ROOT="$PWD/.pyenv"
1515
export PATH="$PYENV_ROOT/bin:$PATH"
1616
eval "$(pyenv init -)"
17-
pyenv global "pypy-${PYPY_VERSION}"
17+
pyenv global "pypy${PYPY_VERSION}"
1818
fi
1919
fi
2020
source $PWD/.venv/bin/activate

HISTORY.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ Release History
66
Upcoming
77
++++++++
88

9-
1.5.3
9+
1.5.4
10+
++++++++++++++++++
11+
12+
- Bugfix so that the return value of ``JWTAuth.refresh()`` correctly matches
13+
that of the auth interface (by returning a tuple of
14+
((access token), (refresh token or None)), instead of just the access token).
15+
In particular, this fixes an exception in ``BoxSession`` that always occurred
16+
when it tried to refresh any ``JWTAuth`` object.
17+
- Fixed an exception that was being raised from ``ExtendableEnumMeta.__dir__()``.
18+
- CPython 3.6 support.
19+
20+
1.5.3 (2016-05-26)
1021
++++++++++++++++++
1122

1223
- Bugfix so that ``JWTAuth`` opens the PEM private key file in ``'rb'`` mode.

README.rst

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,34 @@ Installing
2828

2929
.. code-block:: console
3030
31-
pip install boxsdk
32-
31+
pip install "boxsdk>=1.5,<2.0"
32+
33+
Important Versioning Note
34+
-------------------------
35+
36+
The production version of the ``boxsdk`` package is the 1.5.x release track.
37+
The code can be found on Github at
38+
<https://github.com/box/box-python-sdk/tree/1.5>. This is what will be
39+
installed with ``pip install boxsdk``.
40+
41+
The development version of the ``boxsdk`` package is the 2.0.0 release track,
42+
currently in an alpha release. The code can be found on Github at
43+
<https://github.com/box/box-python-sdk/tree/master>. This isn't installed by
44+
``pip`` by default, but can be installed if specifying a specific version. For
45+
example, ``pip install boxsdk==2.0.0a5``. We welcome early testing and feedback
46+
on these alpha releases. Note that while we're still in alpha, version 2.0.0 is
47+
subject to change, and there might be breaking changes between alpha releases
48+
(e.g. between 2.0.0a2 and 2.0.0a3).
49+
50+
The 1.5.x release track will receive bugfix support at least until the final
51+
release of 2.0.0.
52+
53+
We always recommend pinning to a specific version (e.g. by adding
54+
``boxsdk==1.5.3`` in your ``requirements.txt`` file), so that you don't risk
55+
accidentally upgrading to a new version and breaking your application. This is
56+
particularly important with the upcoming 2.0.0 release. There will be some
57+
breaking changes in version 2.0.0, which might break your application if you
58+
upgrade without adapting your code first.
3359

3460
Authorization
3561
-------------
@@ -418,8 +444,8 @@ Run all tests using -
418444
419445
The tox tests include code style checks via pep8 and pylint.
420446

421-
The tox tests are configured to run on Python 2.6, 2.7, 3.3, 3.4, 3.5, and
422-
PyPy (our CI is configured to run PyPy tests on PyPy 4.0).
447+
The tox tests are configured to run on Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, and
448+
PyPy2.7 (our CI is configured to run PyPy2.7 tests on PyPy2.7 5.8.0).
423449

424450

425451
Support

boxsdk/auth/jwt_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def _refresh(self, access_token):
193193
"""
194194
# pylint:disable=unused-argument
195195
if self._user_id is None:
196-
return self.authenticate_instance()
196+
new_access_token = self.authenticate_instance()
197197
else:
198-
return self._auth_with_jwt(self._user_id, 'user')
198+
new_access_token = self._auth_with_jwt(self._user_id, 'user')
199+
return new_access_token, None

boxsdk/auth/oauth2.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ def refresh(self, access_token_to_refresh):
203203
# The lock here is for handling that case that multiple requests fail, due to access token expired, at the
204204
# same time to avoid multiple session renewals.
205205
if (access_token is None) or (access_token_to_refresh == access_token):
206-
# If the active access token is the same as the token needs to
206+
# If the active access token is the same as the token that needs to
207207
# be refreshed, or if we don't currently have any active access
208208
# token, we make the request to refresh the token.
209-
return self._refresh(access_token_to_refresh)
210-
else:
211-
# If the active access token (self._access_token) is not the same as the token needs to be refreshed,
212-
# it means the expired token has already been refreshed. Simply return the current active tokens.
213-
return access_token, refresh_token
209+
access_token, refresh_token = self._refresh(access_token_to_refresh)
210+
# Else, if the active access token (self._access_token) is not the same as the token needs to be refreshed,
211+
# it means the expired token has already been refreshed. Simply return the current active tokens.
212+
return access_token, refresh_token
214213

215214
@staticmethod
216215
def _get_state_csrf_token():

boxsdk/object/events.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# coding: utf-8
22

3-
from __future__ import unicode_literals
4-
3+
from __future__ import unicode_literals, absolute_import
54
from requests.exceptions import Timeout
6-
from six import with_metaclass
75

8-
from boxsdk.object.base_endpoint import BaseEndpoint
9-
from boxsdk.util.enum import ExtendableEnumMeta
10-
from boxsdk.util.lru_cache import LRUCache
11-
from boxsdk.util.text_enum import TextEnum
6+
from .base_endpoint import BaseEndpoint
7+
from ..util.compat import with_metaclass
8+
from ..util.enum import ExtendableEnumMeta
9+
from ..util.lru_cache import LRUCache
10+
from ..util.text_enum import TextEnum
1211

1312

1413
# pylint:disable=too-many-ancestors
@@ -55,6 +54,7 @@ class Events(BaseEndpoint):
5554

5655
def get_url(self, *args):
5756
"""Base class override."""
57+
# pylint:disable=arguments-differ
5858
return super(Events, self).get_url('events', *args)
5959

6060
def get_events(self, limit=100, stream_position=0, stream_type=UserEventsStreamType.ALL):

0 commit comments

Comments
 (0)