|
6 | 6 | from django import http
|
7 | 7 | from django.contrib.auth.mixins import LoginRequiredMixin
|
8 | 8 | from django.contrib.auth.views import redirect_to_login
|
9 |
| -from django.http import HttpResponse |
| 9 | +from django.http import HttpResponse, JsonResponse |
10 | 10 | from django.shortcuts import resolve_url
|
11 | 11 | from django.utils import timezone
|
12 | 12 | from django.utils.decorators import method_decorator
|
@@ -323,10 +323,20 @@ def device_flow_token_response(
|
323 | 323 | device = Device.objects.get(device_code=device_code)
|
324 | 324 |
|
325 | 325 | if device.status == device.AUTHORIZATION_PENDING:
|
326 |
| - raise AuthorizationPendingError |
| 326 | + pending_error = AuthorizationPendingError() |
| 327 | + return http.HttpResponse( |
| 328 | + content=pending_error.json, |
| 329 | + status=pending_error.status_code, |
| 330 | + content_type="application/json" |
| 331 | + ) |
327 | 332 |
|
328 | 333 | if device.status == device.DENIED:
|
329 |
| - raise AccessDenied |
| 334 | + access_denied_error = AccessDenied() |
| 335 | + return http.HttpResponse( |
| 336 | + content=access_denied_error.json, |
| 337 | + status=access_denied_error.status_code, |
| 338 | + content_type="application/json" |
| 339 | + ) |
330 | 340 |
|
331 | 341 | url, headers, body, status = self.create_token_response(request)
|
332 | 342 |
|
|
0 commit comments