Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ OAuth Error Handling
client_id=client_id,
client_secret=client_secret
)
token = await credential_helper.get_token()
token_data = credential_helper.get_token()
access_token = token_data.access_token
except OAuthError as e:
logger.error(f"OAuth authentication failed: {e}")
# Handle OAuth failure - check credentials
Expand Down
19 changes: 6 additions & 13 deletions docs/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ Set these environment variables for OAuth authentication:
audience=os.getenv("OAUTH_AUDIENCE", "crisp-athena-live"),
)

# Test token acquisition
try:
token = await credential_helper.get_token()
print(f"Successfully acquired token (length: {len(token)})")
except Exception as e:
print(f"Failed to acquire OAuth token: {e}")
return

# Create authenticated channel
channel = await create_channel_with_credentials(
host=os.getenv("ATHENA_HOST"),
Expand Down Expand Up @@ -258,11 +250,12 @@ Handle OAuth-specific errors gracefully:

.. code-block:: python

from resolver_athena_client.client.exceptions import AuthenticationError
from resolver_athena_client.client.exceptions import OAuthError

try:
token = await credential_helper.get_token()
except AuthenticationError as e:
token_data = credential_helper.get_token()
access_token = token_data.access_token
except OAuthError as e:
logger.error(f"OAuth authentication failed: {e}")
# Handle authentication failure
except Exception as e:
Expand Down Expand Up @@ -356,8 +349,8 @@ Test your authentication setup:
client_secret=os.getenv("OAUTH_CLIENT_SECRET"),
)

token = await credential_helper.get_token()
print(f"✓ Authentication successful (token length: {len(token)})")
token_data = credential_helper.get_token()
print(f"✓ Authentication successful (token length: {len(token_data.access_token)})")
return True

except Exception as e:
Expand Down
9 changes: 0 additions & 9 deletions examples/classify_single_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ async def main() -> int:
audience=audience,
)

# Test token acquisition
try:
logger.info("Acquiring OAuth token...")
token = await credential_helper.get_token()
logger.info("Successfully acquired token (length: %d)", len(token))
except Exception:
logger.exception("Failed to acquire OAuth token")
return 1

# Configure client options
options = AthenaOptions(
host=host,
Expand Down
9 changes: 0 additions & 9 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,6 @@ async def main() -> int:
audience=audience,
)

# Test token acquisition
try:
logger.info("Acquiring OAuth token...")
token = await credential_helper.get_token()
logger.info("Successfully acquired token (length: %d)", len(token))
except Exception:
logger.exception("Failed to acquire OAuth token")
return 1

# Get available deployment
channel = await create_channel_with_credentials(host, credential_helper)
async with DeploymentSelector(channel) as deployment_selector:
Expand Down
2 changes: 2 additions & 0 deletions src/resolver_athena_client/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from resolver_athena_client.client.channel import (
CredentialHelper,
TokenData,
create_channel_with_credentials,
)
from resolver_athena_client.client.exceptions import (
Expand All @@ -26,6 +27,7 @@
"CredentialError",
"CredentialHelper",
"OAuthError",
"TokenData",
"TokenExpiredError",
"create_channel_with_credentials",
"get_output_error_summary",
Expand Down
Loading