Skip to content

Commit

Permalink
Fix: Unauthorized Access Error For PAR (#671)
Browse files Browse the repository at this point in the history
### 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).
  • Loading branch information
arpit-jn authored Feb 13, 2025
2 parents 5564a75 + d8e14f8 commit 2bcc956
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions auth0/authentication/pushed_authorization_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .base import AuthenticationBase



class PushedAuthorizationRequests(AuthenticationBase):
"""Pushed Authorization Request (PAR) endpoint"""

Expand All @@ -24,9 +25,11 @@ def pushed_authorization_request(
return self.authenticated_post(
f"{self.protocol}://{self.domain}/oauth/par",
data={
"client_id": self.client_id,
"client_id":self.client_id,
"client_secret":self.client_secret,
"response_type": response_type,
"redirect_uri": redirect_uri,
**kwargs,
},
)
headers={"Content-Type": "application/x-www-form-urlencoded"},
)
7 changes: 7 additions & 0 deletions auth0/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from random import randint
from time import sleep
from typing import TYPE_CHECKING, Any, Mapping
from urllib.parse import urlencode

import requests

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

if data is None and json is not None and headers:
content_type = headers.get("Content-Type", "").lower() # Get Content-Type
if "application/x-www-form-urlencoded" in content_type:
data = urlencode(json) # Copy JSON data into data
json = None # Prevent JSON from being sent

kwargs = {
k: v
for k, v in {
Expand Down

0 comments on commit 2bcc956

Please sign in to comment.