diff options
| author | Pierre Dulac | 2013-03-01 11:53:30 +0100 |
|---|---|---|
| committer | Pierre Dulac | 2013-03-01 11:53:30 +0100 |
| commit | 9d5c3060386cc8deb4ee55eda022f0a134e897c0 (patch) | |
| tree | d1e36104f7cdc6f3980d630ac58299e148ddcc78 /rest_framework/authentication.py | |
| parent | aed3c13471deae6b2837b3799b4ca6615a5d172c (diff) | |
| download | django-rest-framework-9d5c3060386cc8deb4ee55eda022f0a134e897c0.tar.bz2 | |
Improve the `django-oauth2-provider` import block
to avoid naming collision with `oauth2` used for OAuth 1
Diffstat (limited to 'rest_framework/authentication.py')
| -rw-r--r-- | rest_framework/authentication.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index c20d9cb5..c94af405 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -6,7 +6,7 @@ from django.contrib.auth import authenticate from django.utils.encoding import DjangoUnicodeDecodeError from rest_framework import exceptions, HTTP_HEADER_ENCODING from rest_framework.compat import CsrfViewMiddleware -from rest_framework.compat import oauth2_provider, oauth2 +from rest_framework.compat import oauth2_provider from rest_framework.authtoken.models import Token import base64 @@ -190,13 +190,13 @@ class OAuth2Authentication(BaseAuthentication): """ # authenticate the client - oauth2_client_form = oauth2.forms.ClientAuthForm(request.REQUEST) + oauth2_client_form = oauth2_provider.forms.ClientAuthForm(request.REQUEST) if not oauth2_client_form.is_valid(): raise exceptions.AuthenticationFailed("Client could not be validated") client = oauth2_client_form.cleaned_data.get('client') - # retrieve the `oauth2.models.OAuth2AccessToken` instance from the access_token - auth_backend = oauth2.backends.AccessTokenBackend() + # retrieve the `oauth2_provider.models.OAuth2AccessToken` instance from the access_token + auth_backend = oauth2_provider.backends.AccessTokenBackend() token = auth_backend.authenticate(access_token, client) if token is None: raise exceptions.AuthenticationFailed("Invalid token") # does not exist or is expired @@ -204,7 +204,7 @@ class OAuth2Authentication(BaseAuthentication): # TODO check scope # try: # self.validate_token(request, consumer, token) - # except oauth2.Error, e: + # except oauth2_provider.Error, e: # print "got e" # raise exceptions.AuthenticationFailed(e.message) |
