workbench.oauth.OAuth

workbench.oauth.OAuth(ctx)

OAuth resource manager for Workbench.

Provides access to OAuth credentials, integrations, and Azure delegated tokens.

Methods

Name Description
get_credentials Retrieve OAuth credentials for a given integration ID.
get_delegated_azure_token Get an Azure delegated access token.

get_credentials

workbench.oauth.OAuth.get_credentials(audience)

Retrieve OAuth credentials for a given integration ID.

Parameters

Name Type Description Default
audience str The ID of the OAuth integration. required

Returns

Name Type Description
Credentials | None The OAuth credentials if found, otherwise None.

get_delegated_azure_token

workbench.oauth.OAuth.get_delegated_azure_token(resource)

Get an Azure delegated access token.

Retrieves an OAuth2 access token from Azure Active Directory for the specified resource. This is used when Workbench is configured with Azure AD authentication and you need to access Azure resources on behalf of the authenticated user.

Parameters

Name Type Description Default
resource str The resource URL for which to request the token. For example: - “https://management.azure.com/” for Azure Resource Manager - “https://storage.azure.com/” for Azure Storage - “https://graph.microsoft.com/” for Microsoft Graph Must be a non-empty string. required

Returns

Name Type Description
AzureToken A dictionary containing the access token and metadata including: - access_token: The OAuth2 bearer token - token_type: The token type (typically “Bearer”) - expires_in: Token lifetime in seconds - scope: Granted scopes (optional) - ext_expires_in: Extended expiration for Azure (optional)

Raises

Name Type Description
ValueError If resource is empty or not a string.
RuntimeError If the backend returns an error response, which may occur if: - Workbench is not configured with Azure AD authentication - The resource URL is invalid or not authorized - The user lacks necessary permissions