Skip to content

Commit a77205c

Browse files
committed
Fix bug inserted by pyflakes inspired cleanup earlier -- it turns out that _get_version() wasn't dead code but was having a necessary side-effect. Add new method named _check_version() to be clearer about what it does compared to _get_version()
1 parent dee4093 commit a77205c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

oauth2/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ def add_signature_method(self, signature_method):
605605
def verify_request(self, request, consumer, token):
606606
"""Verifies an api call and checks all the parameters."""
607607

608+
self._check_version(request)
608609
self._check_signature(request, consumer, token)
609610
parameters = request.get_nonoauth_parameters()
610611
return parameters
@@ -613,16 +614,19 @@ def build_authenticate_header(self, realm=''):
613614
"""Optional support for the authenticate header."""
614615
return {'WWW-Authenticate': 'OAuth realm="%s"' % realm}
615616

617+
def _check_version(self, request):
618+
"""Verify the correct version of the request for this server."""
619+
version = self._get_version(request)
620+
if version and version != self.version:
621+
raise Error('OAuth version %s not supported.' % str(version))
622+
616623
def _get_version(self, request):
617-
"""Verify the correct version request for this server."""
624+
"""Return the version of the request for this server."""
618625
try:
619626
version = request.get_parameter('oauth_version')
620627
except:
621628
version = OAUTH_VERSION
622629

623-
if version and version != self.version:
624-
raise Error('OAuth version %s not supported.' % str(version))
625-
626630
return version
627631

628632
def _get_signature_method(self, request):

0 commit comments

Comments
 (0)