Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Release History
Upcoming
++++++++

1.3.3 (2016-01-04)
++++++++++++++++++

**Bugfixes**

- Fixed import error for installations that don't have redis installed.
- Fixed use of ``raw_input`` in the developer token auth for py3 compatibility.


1.3.3 (2015-12-22)
++++++++++++++++++

Expand Down
11 changes: 9 additions & 2 deletions boxsdk/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
try:
from .jwt_auth import JWTAuth
except ImportError:
JWTAuth = None # If extras are not installed, JWTAuth won't be available.
JWTAuth = None # If extras[jwt] are not installed, JWTAuth won't be available.
from .oauth2 import OAuth2
from .redis_managed_oauth2 import RedisManagedJWTAuth, RedisManagedOAuth2
try:
from .redis_managed_oauth2 import RedisManagedOAuth2
except ImportError:
RedisManagedOAuth2 = None # If extras[redis] are not installed, RedisManagedOAuth2 won't be available.
try:
from .redis_managed_jwt_auth import RedisManagedJWTAuth
except ImportError:
RedisManagedJWTAuth = None # If extras[jwt,redis] are not installed, RedisManagedJWTAuth won't be available.
from .remote_managed_oauth2 import RemoteOAuth2
4 changes: 3 additions & 1 deletion boxsdk/auth/developer_token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import unicode_literals, absolute_import

from six.moves import input # pylint:disable=redefined-builtin

from .oauth2 import OAuth2


Expand All @@ -21,7 +23,7 @@ def _refresh_developer_token(self):
if self._get_new_token is not None:
return self._get_new_token()
else:
return raw_input(self.ENTER_TOKEN_PROMPT)
return input(self.ENTER_TOKEN_PROMPT)

def _refresh(self, access_token):
"""
Expand Down
17 changes: 17 additions & 0 deletions boxsdk/auth/redis_managed_jwt_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding: utf-8

from __future__ import unicode_literals, absolute_import

from .jwt_auth import JWTAuth
from .redis_managed_oauth2 import RedisManagedOAuth2Mixin


class RedisManagedJWTAuth(RedisManagedOAuth2Mixin, JWTAuth):
"""
JWT Auth subclass which uses Redis to manage access tokens.
"""
def _auth_with_jwt(self, sub, sub_type):
"""
Base class override. Returns the access token in a tuple to match the OAuth2 interface.
"""
return super(RedisManagedJWTAuth, self)._auth_with_jwt(sub, sub_type), None
12 changes: 0 additions & 12 deletions boxsdk/auth/redis_managed_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from redis import StrictRedis
from redis.lock import Lock

from .jwt_auth import JWTAuth
from .oauth2 import OAuth2


Expand Down Expand Up @@ -69,14 +68,3 @@ class RedisManagedOAuth2(RedisManagedOAuth2Mixin):
OAuth2 subclass which uses Redis to manage tokens.
"""
pass


class RedisManagedJWTAuth(RedisManagedOAuth2Mixin, JWTAuth):
"""
JWT Auth subclass which uses Redis to manage access tokens.
"""
def _auth_with_jwt(self, sub, sub_type):
"""
Base class override. Returns the access token in a tuple to match the OAuth2 interface.
"""
return super(RedisManagedJWTAuth, self)._auth_with_jwt(sub, sub_type), None
8 changes: 8 additions & 0 deletions docs/source/boxsdk.auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ boxsdk.auth.oauth2 module
:undoc-members:
:show-inheritance:

boxsdk.auth.redis_managed_jwt_auth module
-----------------------------------------

.. automodule:: boxsdk.auth.redis_managed_jwt_auth
:members:
:undoc-members:
:show-inheritance:

boxsdk.auth.redis_managed_oauth2 module
---------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def main():
install_requires.append('ordereddict>=1.1')
setup(
name='boxsdk',
version='1.3.3',
version='1.3.4',
description='Official Box Python SDK',
long_description=open(join(base_dir, 'README.rst')).read(),
author='Box',
Expand Down
2 changes: 1 addition & 1 deletion test/unit/auth/test_developer_token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_developer_token_auth_calls_callback_during_init_and_refresh(access_toke


def test_developer_token_auth_uses_raw_input_by_default(access_token):
with patch('boxsdk.auth.developer_token_auth.raw_input', create=True) as mock_raw_input:
with patch('boxsdk.auth.developer_token_auth.input', create=True) as mock_raw_input:
mock_raw_input.return_value = access_token
auth = developer_token_auth.DeveloperTokenAuth()
mock_raw_input.assert_called_once_with(auth.ENTER_TOKEN_PROMPT)
Expand Down