Skip to content

Commit ff43d06

Browse files
authored
Merge branch 'master' into patch-1
2 parents 0a59a1e + 3716ec4 commit ff43d06

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

‎AUTHORS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Alan Crosswell
1212
Aleksander Vaskevich
1313
Alessandro De Angelis
1414
Allisson Azevedo
15+
Andrew Chen Wang
1516
Anvesh Agarwal
1617
Aristóbulo Meneses
1718
Aryan Iyappan

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
## [unreleased]
1818
* Remove support for Django 3.0
1919
* Add support for Django 3.2
20+
*#989 Change any HttpResponse to JsonResponse if possible
2021

2122
### Added
2223
*#712, #636, #808. Calls to `django.contrib.auth.authenticate()` now pass a `request`

‎oauth2_provider/models.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -563,56 +563,56 @@ class Meta(AbstractIDToken.Meta):
563563

564564

565565
defget_application_model():
566-
"""Return the Application model that is active in this project."""
566+
"""Return the Application model that is active in this project."""
567567
returnapps.get_model(oauth2_settings.APPLICATION_MODEL)
568568

569569

570570
defget_grant_model():
571-
"""Return the Grant model that is active in this project."""
571+
"""Return the Grant model that is active in this project."""
572572
returnapps.get_model(oauth2_settings.GRANT_MODEL)
573573

574574

575575
defget_access_token_model():
576-
"""Return the AccessToken model that is active in this project."""
576+
"""Return the AccessToken model that is active in this project."""
577577
returnapps.get_model(oauth2_settings.ACCESS_TOKEN_MODEL)
578578

579579

580580
defget_id_token_model():
581-
"""Return the AccessToken model that is active in this project."""
581+
"""Return the AccessToken model that is active in this project."""
582582
returnapps.get_model(oauth2_settings.ID_TOKEN_MODEL)
583583

584584

585585
defget_refresh_token_model():
586-
"""Return the RefreshToken model that is active in this project."""
586+
"""Return the RefreshToken model that is active in this project."""
587587
returnapps.get_model(oauth2_settings.REFRESH_TOKEN_MODEL)
588588

589589

590590
defget_application_admin_class():
591-
"""Return the Application admin class that is active in this project."""
591+
"""Return the Application admin class that is active in this project."""
592592
application_admin_class=oauth2_settings.APPLICATION_ADMIN_CLASS
593593
returnapplication_admin_class
594594

595595

596596
defget_access_token_admin_class():
597-
"""Return the AccessToken admin class that is active in this project."""
597+
"""Return the AccessToken admin class that is active in this project."""
598598
access_token_admin_class=oauth2_settings.ACCESS_TOKEN_ADMIN_CLASS
599599
returnaccess_token_admin_class
600600

601601

602602
defget_grant_admin_class():
603-
"""Return the Grant admin class that is active in this project."""
603+
"""Return the Grant admin class that is active in this project."""
604604
grant_admin_class=oauth2_settings.GRANT_ADMIN_CLASS
605605
returngrant_admin_class
606606

607607

608608
defget_id_token_admin_class():
609-
"""Return the IDToken admin class that is active in this project."""
609+
"""Return the IDToken admin class that is active in this project."""
610610
id_token_admin_class=oauth2_settings.ID_TOKEN_ADMIN_CLASS
611611
returnid_token_admin_class
612612

613613

614614
defget_refresh_token_admin_class():
615-
"""Return the RefreshToken admin class that is active in this project."""
615+
"""Return the RefreshToken admin class that is active in this project."""
616616
refresh_token_admin_class=oauth2_settings.REFRESH_TOKEN_ADMIN_CLASS
617617
returnrefresh_token_admin_class
618618

‎oauth2_provider/views/introspect.py‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
importcalendar
2-
importjson
32

43
fromdjango.core.exceptionsimportObjectDoesNotExist
5-
fromdjango.httpimportHttpResponse
4+
fromdjango.httpimportJsonResponse
65
fromdjango.utils.decoratorsimportmethod_decorator
76
fromdjango.views.decorators.csrfimportcsrf_exempt
87

@@ -29,9 +28,7 @@ def get_token_response(token_value=None):
2928
get_access_token_model().objects.select_related("user", "application").get(token=token_value)
3029
)
3130
exceptObjectDoesNotExist:
32-
returnHttpResponse(
33-
content=json.dumps({"active": False}), status=401, content_type="application/json"
34-
)
31+
returnJsonResponse({"active": False}, status=401)
3532
else:
3633
iftoken.is_valid():
3734
data={
@@ -43,17 +40,9 @@ def get_token_response(token_value=None):
4340
data["client_id"] =token.application.client_id
4441
iftoken.user:
4542
data["username"] =token.user.get_username()
46-
returnHttpResponse(content=json.dumps(data), status=200, content_type="application/json")
43+
returnJsonResponse(data)
4744
else:
48-
returnHttpResponse(
49-
content=json.dumps(
50-
{
51-
"active": False,
52-
}
53-
),
54-
status=200,
55-
content_type="application/json",
56-
)
45+
returnJsonResponse({"active": False})
5746

5847
defget(self, request, *args, **kwargs):
5948
"""

0 commit comments

Comments
(0)