diff --git a/auth0/authentication/pushed_authorization_requests.py b/auth0/authentication/pushed_authorization_requests.py index 0d5492bc..12c4fc97 100644 --- a/auth0/authentication/pushed_authorization_requests.py +++ b/auth0/authentication/pushed_authorization_requests.py @@ -3,6 +3,7 @@ from .base import AuthenticationBase + class PushedAuthorizationRequests(AuthenticationBase): """Pushed Authorization Request (PAR) endpoint""" @@ -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"}, + ) \ No newline at end of file diff --git a/auth0/rest.py b/auth0/rest.py index 0b91323d..196ad7ac 100644 --- a/auth0/rest.py +++ b/auth0/rest.py @@ -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 @@ -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 {