Skip to content

Commit 96e1c85

Browse files
duzumakidopry
authored andcommitted
Adhere content-type request header to CGI standard
Django represents headers according to the common gateway interface(CGI) standard. This means it's in all caps with words divided with a hyphen However a lot of libraries follow the pattern of Something-Something so this ensures the header is set correctly so libraries like oauthlib can read it
1 parent fe76b5e commit 96e1c85

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

oauth2_provider/oauth2_backends.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from urllib.parse import urlparse, urlunparse
33

4+
from django.http import HttpRequest
45
from oauthlib import oauth2
56
from oauthlib.common import Request as OauthlibRequest
67
from oauthlib.common import quote, urlencode, urlencoded
@@ -75,6 +76,8 @@ def extract_headers(self, request):
7576
del headers["wsgi.errors"]
7677
if "HTTP_AUTHORIZATION" in headers:
7778
headers["Authorization"] = headers["HTTP_AUTHORIZATION"]
79+
if "CONTENT_TYPE" in headers:
80+
headers["Content-Type"] = headers["CONTENT_TYPE"]
7881
# Add Access-Control-Allow-Origin header to the token endpoint response for authentication code grant,
7982
# if the origin is allowed by RequestValidator.is_origin_allowed.
8083
# https://github.com/oauthlib/oauthlib/pull/791

0 commit comments

Comments
 (0)