Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error descriptions for invalid_requests #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions provider/oauth2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def to_python(self, value):
return []

if not isinstance(value, (list, tuple)):
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'ScopeChoiceField.to_python value was not list'})

# Split values into list
return u' '.join([smart_unicode(val) for val in value]).split(u' ')
Expand All @@ -67,7 +67,7 @@ def validate(self, value):
Validates that the input is a list or tuple.
"""
if self.required and not value:
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'ScopeChoiceField.validate required not value'})

# Validate that each value in the value list is in self.choices.
for val in value:
Expand Down Expand Up @@ -197,7 +197,7 @@ def clean_refresh_token(self):
token = self.cleaned_data.get('refresh_token')

if not token:
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'RefreshTokenGrantForm.clean_refresh_token'})

try:
token = RefreshToken.objects.get(token=token,
Expand Down Expand Up @@ -238,13 +238,13 @@ def clean_code(self):
code = self.cleaned_data.get('code')

if not code:
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'AuthorizationCodeGrantForm.clean_code not code'})

try:
self.cleaned_data['grant'] = Grant.objects.get(
code=code, client=self.client, expires__gt=now())
except Grant.DoesNotExist:
raise OAuthValidationError({'error': 'invalid_grant'})
raise OAuthValidationError({'error': 'invalid_grant', 'error_description': 'AuthorizationCodeGrantForm.clean_code Grant.DoesNotExist'})

return code

Expand Down Expand Up @@ -278,15 +278,15 @@ def clean_username(self):
username = self.cleaned_data.get('username')

if not username:
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'PasswordGrantForm.clean_username not username'})

return username

def clean_password(self):
password = self.cleaned_data.get('password')

if not password:
raise OAuthValidationError({'error': 'invalid_request'})
raise OAuthValidationError({'error': 'invalid_request', 'error_description': 'PasswordGrantForm.clean_password not password'})

return password

Expand Down