Learn how to handle expired credentials gracefully by refreshing the token and resuming the tool execution
AuthRequiredError
): Occurs when no authentication configuration exists for an API.OAuthCredentialsRequiredException
): Occurs when OAuth credentials are expired or invalid.AuthRequiredError
register_api_auth
before running the tool.OAuthCredentialsRequiredException
containing information needed to refresh the token
OAuthCredentialsRequiredException
contains two important pieces of information:
oauth_info
: Contains details about the OAuth requirementsresume_info
: Contains information needed to resume the tool executionresume_tool
method of the WildcardClient
. This method takes the ResumeToolExecutionInfo
object that was provided in the exception:
resume_tool
method will:
resume_info
contains everything needed to retry the operation. You can store it and resume the execution later, for example after the user re-authenticates in your UI.AuthRequiredError
and OAuthCredentialsRequiredException
.resume_info
to retry the operation after re-authentication.