8000 Fix: Unauthorized Access Error For PAR (#671) · auth0/auth0-python@2bcc956 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2bcc956

Browse files
authored
Fix: Unauthorized Access Error For PAR (#671)
### Changes - Fix for `401: Unauthorized `for PAR Requests ### Contributor Checklist - [x] I agree to adhere to the [Auth0 General Contribution Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md). - [x] I agree to uphold the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
2 parents 5564a75 + d8e14f8 commit 2bcc956

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

auth0/authentication/pushed_authorization_requests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .base import AuthenticationBase
44

55

6+
67
class PushedAuthorizationRequests(AuthenticationBase):
78
"""Pushed Authorization Request (PAR) endpoint"""
89

@@ -24,9 +25,11 @@ def pushed_authorization_request(
2425
return self.authenticated_post(
2526
f"{self.protocol}://{self.domain}/oauth/par",
2627
data={
27-
"client_id": self.client_id,
28+
"client_id":self.client_id,
29+
"client_secret":self.client_secret,
2830
"response_type": response_type,
2931
"redirect_uri": redirect_uri,
3032
**kwargs,
3133
},
32-
)
34+
headers={"Content-Type": "application/x-www-form-urlencoded"},
35+
)

auth0/rest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from random import randint
88
from time import sleep
99
from typing import TYPE_CHECKING, Any, Mapping
10+
from urllib.parse import urlencode
1011

1112
import requests
1213

@@ -152,6 +153,12 @@ def _request(
152153
# Reset the metrics tracker
153154
self._metrics = {"retries": 0, "backoff": []}
154155

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

0 commit comments

Comments
 (0)
0