Skip to content

Commit acfdfaa

Browse files
Fix: Unauthorized Access Error For PAR
1 parent 5564a75 commit acfdfaa

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

auth0/authentication/pushed_authorization_requests.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from .base import AuthenticationBase
44

5+
from urllib.parse import urlencode
6+
57

68
class PushedAuthorizationRequests(AuthenticationBase):
79
"""Pushed Authorization Request (PAR) endpoint"""
@@ -21,12 +23,14 @@ def pushed_authorization_request(
2123
2224
See: https://www.rfc-editor.org/rfc/rfc9126.html
2325
"""
24-
return self.authenticated_post(
26+
return self.post(
2527
f"{self.protocol}://{self.domain}/oauth/par",
26-
data={
27-
"client_id": self.client_id,
28+
data=urlencode({
29+
"client_id":self.client_id,
30+
"client_secret":self.client_secret,
2831
"response_type": response_type,
2932
"redirect_uri": redirect_uri,
3033
**kwargs,
31-
},
32-
)
34+
}),
35+
headers={"Content-Type": "application/x-www-form-urlencoded"},
36+
)

auth0/rest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ def _request(
152152
# Reset the metrics tracker
153153
self._metrics = {"retries": 0, "backoff": []}
154154

155+
if data is None and json is not None and headers:
156+
content_type = headers.get("Content-Type", "").lower() # Get Content-Type
157+
if "application/x-www-form-urlencoded" in content_type:
158+
data = json # Copy JSON data into data
159+
json = None # Prevent JSON from being sent
160+
155161
kwargs = {
156162
k: v
157163
for k, v in {

0 commit comments

Comments
 (0)