Skip to content

Commit d93f9c3

Browse files
committed
Fix bad url parameter in error response with invalid redirect_uri
1 parent 472761b commit d93f9c3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

oauth2_provider/views/mixins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ def error_response(self, error, **kwargs):
159159
oauthlib_error = error.oauthlib_error
160160

161161
redirect_uri = oauthlib_error.redirect_uri or ""
162-
separator = '&' if '?' in redirect_uri else '?'
162+
separator = "&" if "?" in redirect_uri else "?"
163163

164164
error_response = {
165-
'error': oauthlib_error,
166-
'url': "{0}{1}{2}".format(oauthlib_error.redirect_uri, separator, oauthlib_error.urlencoded)
165+
"error": oauthlib_error,
166+
"url": redirect_uri + separator + oauthlib_error.urlencoded,
167167
}
168168
error_response.update(kwargs)
169169

tests/test_authorization_code.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def test_pre_auth_invalid_client(self):
117117

118118
response = self.client.get(url)
119119
self.assertEqual(response.status_code, 400)
120+
self.assertEqual(
121+
response.context_data["url"],
122+
"?error=invalid_request&error_description=Invalid+client_id+parameter+value."
123+
)
120124

121125
def test_pre_auth_valid_client(self):
122126
"""

0 commit comments

Comments
 (0)