diff --git a/sanic/request.py b/sanic/request.py index df640df0..fb35c760 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -77,7 +77,7 @@ class Request(dict): :return: token related to request """ - self._token = getattr(self, '_token', + self._token = getattr(self, '_token', self.headers.get('Authorization')) return self._token diff --git a/tests/test_requests.py b/tests/test_requests.py index 7b453fc1..24a607b7 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -141,10 +141,10 @@ def test_token(): return text('OK') # uuid4 generated token. - token = 'a1d895e0-553a-421a-8e22-5ff8ecb48cbf' + token = 'Token a1d895e0-553a-421a-8e22-5ff8ecb48cbf' headers = { 'content-type': 'application/json', - 'Authorization': 'Token {}'.format(token) + 'Authorization': '{}'.format(token) } request, response = app.test_client.get('/', headers=headers)