Understanding ToolContext
What is ToolContext?
ToolContext
is a crucial component in Arcade that manages authorization and user information for tools requiring authentication. Let’s explore how it works and how you can use it in your projects.
ToolContext
is a class that holds two main pieces of information:
- Authorization context: This includes a token for making authenticated requests to external APIs as well as structured user information for providers that support retrieving user information.
- User ID: This identifies the user invoking the tool.
Some authorization providers may also include additional structured user information in the ToolContext
.
How ToolContext Works
When you invoke a tool that requires authorization, Arcade’s Tool SDK automatically:
- Creates a
ToolContext
object - Passes this object to your tool
You can then use the ToolContext
object to make authenticated requests to external APIs.
Next Steps
Now that you understand the basics of ToolContext
, you’re ready to apply this knowledge in creating your own authorized tools. To learn how to build a custom tool that requires user authorization, check out our guide on Adding user authorization to your tools.