ayush786hack commented on code in PR #13676:
URL: https://github.com/apache/gravitino/pull/13676#discussion_r4237242666
##########
clients/client-python/gravitino/auth/default_oauth2_token_provider.py:
##########
@@ -103,16 +108,39 @@ def _parse_credential(self):
def _fetch_token(self) -> str:
client_id, client_secret = self._parse_credential()
- client_credential_request = OAuth2ClientCredentialRequest(
- grant_type=CLIENT_CREDENTIALS,
- client_id=client_id,
- client_secret=client_secret,
- scope=self._scope,
- )
+ headers = {}
+
+ if (
+ self._authentication_method
+ == OAuth2ClientAuthenticationMethod.CLIENT_SECRET_BASIC
+ ):
+ credentials = f"{client_id}:{client_secret}"
+ encoded_credentials = base64.b64encode(
+ credentials.encode("utf-8")
+ ).decode("utf-8")
+
+ headers["Authorization"] = f"Basic {encoded_credentials}"
+
+ client_credential_request = OAuth2ClientCredentialRequest(
+ grant_type=CLIENT_CREDENTIALS,
+ client_id=None,
+ client_secret=None,
+ scope=self._scope,
+
+ )
+
+ else:
+ client_credential_request = OAuth2ClientCredentialRequest(
+ grant_type=CLIENT_CREDENTIALS,
+ client_id=client_id,
+ client_secret=client_secret,
+ scope=self._scope,
+ )
resp = self._client.post_form(
self._path,
data=client_credential_request,
+ headers=headers,
Review Comment:
Fixed. Corrected the indentation of `headers=headers` to align with the
neighboring keyword arguments. The formatting cleanup is pushed to the PR
branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]