--- title: "Checking Tool Auth Status" description: "Guide on checking the auth status of a tool" --- # Checking Tool Authorization Status Before executing tools that require authorization, you can check their authorization status to understand what permissions are needed and whether they're currently available for a user. This is useful for: - Displaying authorization requirements in your UI - Pre-checking tool availability before execution - Understanding which tools need user approval - Debugging authorization issues import { Steps, Tabs, Callout } from "nextra/components"; ### Initialize the client Import the Arcade client in a Python/Javascript script. ```python from arcadepy import Arcade client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable ``` ```js import Arcade from "@arcadeai/arcadejs"; const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable ``` ### Check authorization status for all tools You can get a list of all available tools and check their authorization status for a specific user: ```python USER_ID = "{arcade_user_id}" # Get all tools for the user tools = client.tools.list(user_id=USER_ID) for tool in tools: print(f"Tool: {tool.name}") if tool.requirements: # Check if all requirements are met print(f"Requirements met: {tool.requirements.met}") # Check authorization status if tool.requirements.authorization: print(f"Authorization status: {tool.requirements.authorization.status}") print(f"Token status: {tool.requirements.authorization.token_status}") # Check secret requirements if tool.requirements.secrets: for secret in tool.requirements.secrets: print(f"Secret '{secret.key}' met: {secret.met}") if not secret.met and secret.status_reason: print(f"Reason: {secret.status_reason}") print("---") ``` ```js const userId = "{arcade_user_id}"; // Get all tools for the user const tools = await client.tools.list({ user_id: userId }); tools.items.forEach(tool => { console.log(`Tool: ${tool.name}`); if (tool.requirements) { // Check if all requirements are met console.log(`Requirements met: ${tool.requirements.met}`); // Check authorization status if (tool.requirements.authorization) { console.log(`Authorization status: ${tool.requirements.authorization.status}`); console.log(`Token status: ${tool.requirements.authorization.token_status}`); } // Check secret requirements if (tool.requirements.secrets) { tool.requirements.secrets.forEach(secret => { console.log(`Secret '${secret.key}' met: ${secret.met}`); if (!secret.met && secret.status_reason) { console.log(`Reason: ${secret.status_reason}`); } }); } } console.log("---"); }); ``` If a username is not provided, the Token Status will be excluded and only the requirements for the provider will be shown. ### Check authorization status for a specific tool You can also check the authorization status for a specific tool by name: ```python USER_ID = "{arcade_user_id}" TOOL_NAME = "Gmail.ListEmails" # Get specific tool details tool = client.tools.get(tool_name=TOOL_NAME, user_id=USER_ID) print(f"Tool: {tool.name}") print(f"Description: {tool.description}") if tool.requirements: print(f"All requirements met: {tool.requirements.met}") if tool.requirements.authorization: auth = tool.requirements.authorization print(f"Authorization required: {auth.provider_type}") print(f"Authorization status: {auth.status}") print(f"Token status: {auth.token_status}") if auth.status_reason: print(f"Status reason: {auth.status_reason}") if tool.requirements.secrets: print("Secret requirements:") for secret in tool.requirements.secrets: status = "✓" if secret.met else "✗" print(f" {status} {secret.key}") ``` ```js const userId = "{arcade_user_id}"; const toolName = "Gmail.ListEmails"; // Get specific tool details const tool = await client.tools.get(toolName, { user_id: userId }); console.log(`Tool: ${tool.name}`); console.log(`Description: ${tool.description}`); if (tool.requirements) { console.log(`All requirements met: ${tool.requirements.met}`); if (tool.requirements.authorization) { const auth = tool.requirements.authorization; console.log(`Authorization required: ${auth.provider_type}`); console.log(`Authorization status: ${auth.status}`); console.log(`Token status: ${auth.token_status}`); if (auth.status_reason) { console.log(`Status reason: ${auth.status_reason}`); } } if (tool.requirements.secrets) { console.log("Secret requirements:"); tool.requirements.secrets.forEach(secret => { const status = secret.met ? "✓" : "✗"; console.log(` ${status} ${secret.key}`); }); } } ``` ### Understanding the status values #### Authorization Status - `active`: If the provider is configured and enabled - `inactive`: Authorization is not found or is disabled #### Token Status - `not_started`: Authorization process hasn't begun - `pending`: Authorization is in progress (user needs to approve) - `completed`: Authorization is complete and tokens are available - `failed`: Authorization process failed #### Requirements Met - `true`: All requirements for the tool are satisfied - `false`: Some requirements are missing (authorization, secrets, etc.) #### Secret Met - `true`: The secret exists for the tool - `false`: The secret does not exist for the tool