Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWang committed Jul 5, 2024
1 parent ccca01f commit 0ecc214
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@


class DefaultOAuth2TokenProvider(OAuth2TokenProvider):

"""This class is the default implement of OAuth2TokenProvider."""

_credential: Optional[str]
_scope: Optional[str]
_path: Optional[str]
Expand Down
13 changes: 13 additions & 0 deletions clients/client-python/gravitino/auth/oauth2_token_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ def __init__(self, uri: str):
self._client = HTTPClient(uri)

def has_token_data(self) -> bool:
"""Judge whether AuthDataProvider can provide token data.
Returns:
true if the AuthDataProvider can provide token data otherwise false.
"""
return True

def get_token_data(self) -> Optional[bytes]:
"""Acquire the data of token for authentication. The client will set the token data as HTTP header
Authorization directly. So the return value should ensure token data contain the token header
(eg: Bearer, Basic) if necessary.
Returns:
the token data is used for authentication.
"""
access_token = self._get_access_token()

if access_token is None:
Expand All @@ -32,6 +44,7 @@ def get_token_data(self) -> Optional[bytes]:
)

def close(self):
"""Closes the OAuth2TokenProvider and releases any underlying resources."""
if self._client is not None:
self._client.close()

Expand Down

0 comments on commit 0ecc214

Please sign in to comment.