Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Unauthorized Access Error For PAR #671

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# 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

Check warning on line 160 in auth0/rest.py

View check run for this annotation

Codecov / codecov/patch

auth0/rest.py#L159-L160

Added lines #L159 - L160 were not covered by tests

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