diff options
| author | Tom Christie | 2014-08-19 10:11:10 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-08-19 10:11:10 +0100 | 
| commit | e385a7b8eb6e538698f28128e43fe8bfaefd4e97 (patch) | |
| tree | 3f1cac50c40ec77a0bc5537f1a04628901a4d2ce /rest_framework/authentication.py | |
| parent | 2aad8e4b35c3552a065347d7eccad8bd51938783 (diff) | |
| parent | 48b66ec2a2b744f170034adbdaaa1588e6c14e11 (diff) | |
| download | django-rest-framework-e385a7b8eb6e538698f28128e43fe8bfaefd4e97.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/authentication.py')
| -rw-r--r-- | rest_framework/authentication.py | 14 | 
1 files changed, 7 insertions, 7 deletions
| diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index cbc83574..82cea70f 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -310,6 +310,13 @@ class OAuth2Authentication(BaseAuthentication):          auth = get_authorization_header(request).split() +        if len(auth) == 1: +            msg = 'Invalid bearer header. No credentials provided.' +            raise exceptions.AuthenticationFailed(msg) +        elif len(auth) > 2: +            msg = 'Invalid bearer header. Token string should not contain spaces.' +            raise exceptions.AuthenticationFailed(msg) +          if auth and auth[0].lower() == b'bearer':              access_token = auth[1]          elif 'access_token' in request.POST: @@ -319,13 +326,6 @@ class OAuth2Authentication(BaseAuthentication):          else:              return None -        if len(auth) == 1: -            msg = 'Invalid bearer header. No credentials provided.' -            raise exceptions.AuthenticationFailed(msg) -        elif len(auth) > 2: -            msg = 'Invalid bearer header. Token string should not contain spaces.' -            raise exceptions.AuthenticationFailed(msg) -          return self.authenticate_credentials(request, access_token)      def authenticate_credentials(self, request, access_token): | 
