diff --git a/httpx_auth/_oauth2/client_credentials.py b/httpx_auth/_oauth2/client_credentials.py index ea46520..de7c5d5 100644 --- a/httpx_auth/_oauth2/client_credentials.py +++ b/httpx_auth/_oauth2/client_credentials.py @@ -3,6 +3,8 @@ from typing import Union, Iterable import httpx +import urllib.parse + from httpx_auth._authentication import SupportMultiAuth from httpx_auth._oauth2.common import ( OAuth2BaseAuth, @@ -97,7 +99,10 @@ def request_new_token(self) -> tuple: return (self.state, token, expires_in) if expires_in else (self.state, token) def _configure_client(self, client: httpx.Client): - client.auth = (self.client_id, self.client_secret) + encoded_client = urllib.parse.quote(self.client_id, safe="") + encoded_secret = urllib.parse.quote(self.client_secret, safe="") + + client.auth = (encoded_client, encoded_secret) client.timeout = self.timeout