Skip to content

Commit bfd67a3

Browse files
duzumakidopry
authored andcommitted
Ensure device token errors are returning 400
1 parent 81b7710 commit bfd67a3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

oauth2_provider/views/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,18 @@ def device_flow_token_response(
323323
device = Device.objects.get(device_code=device_code)
324324

325325
if device.status == device.AUTHORIZATION_PENDING:
326-
raise AuthorizationPendingError
326+
pending_error = AuthorizationPendingError()
327+
return http.HttpResponse(
328+
content=pending_error.json, status=pending_error.status_code, content_type="application/json"
329+
)
327330

328331
if device.status == device.DENIED:
329-
raise AccessDenied
332+
access_denied_error = AccessDenied()
333+
return http.HttpResponse(
334+
content=access_denied_error.json,
335+
status=access_denied_error.status_code,
336+
content_type="application/json",
337+
)
330338

331339
url, headers, body, status = self.create_token_response(request)
332340

0 commit comments

Comments
 (0)