You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classBaseAPIClient(AsyncOAuth2Client):
""" Base class for client of API published via integration platform. Authorization is OAUTH 2.0 with client ID """def__init__(
self,
client_id: str,
client_secret: str,
oauth2_token_url: str,
api_base_url: str,
):
super().__init__(
client_id=client_id,
client_secret=client_secret,
scope="email",
)
self._token_url=oauth2_token_urlself._api_base_url=api_base_urlasyncdefstart(self) ->None:
ifnotself.token:
try:
awaitself.fetch_token(url=self._token_url)
exceptException:
self._handle_exception(sys.exc_info(), in_auth=True)
self.headers["Authorization"] =f"Bearer {self.token['access_token']}"logger.info("Authorized successfully", token_url=self._token_url)
def_handle_exception(self, exc_info: tuple, in_auth: bool=False) ->None:
exc_type, exc=exc_info[:2]
ifexc_type==OAuthErrororin_auth:
msg="Failed to authorize on API platform"logger.error(msg, token_url=self._token_url, exc_info=exc_info)
raiseBaseAPIClientError(msg) fromexcmsg="Unexpected API error"logger.error(msg, exc_info=exc_info)
raiseBaseAPIClientError(msg) fromexccc=SupportAPIClient(
client_id=settings.api_reg_client_id,
client_secret=settings.api_reg_client_secret,
oauth2_token_url=settings.api_reg_token_url,
)
awaitcc.start()
# Wait some time for token to expireawaitcc.post(...) # <-- Crashes
Expected behavior
Expected the token to be refreshed / re-obtained and than request complete successfully
Describe the bug
In case of using AsyncOAuth2Client with client credential I'm obtaining a TypeError exception after token expiration when making POST request.
Error Stacks
To Reproduce
My code simplified:
Expected behavior
Expected the token to be refreshed / re-obtained and than request complete successfully
Environment:
Additional context
The problem seems to originate from line:
authlib/authlib/oauth2/client.py
Line 275 in 610622e
In case of client credentials there are both no
token_endpoint
in metadata andurl
in token.Token data:
Metadata:
Is it intended, a bug or my client misconfiguration?
The text was updated successfully, but these errors were encountered: