-
Notifications
You must be signed in to change notification settings - Fork 14
[TOO-1175] docs(auth-providers): add Sentry provider page #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
EricGustin
wants to merge
2
commits into
main
Choose a base branch
from
ericgustin/sentry-auth-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| import { Tabs, Callout, Steps } from "nextra/components"; | ||
|
|
||
| # Sentry | ||
|
|
||
| The Sentry auth provider enables tools and agents to call the [Sentry API](https://docs.sentry.io/api/) on behalf of a user. | ||
|
|
||
| ### What's documented here | ||
|
|
||
| This page describes how to use and configure Sentry auth with Arcade. | ||
|
|
||
| This auth provider is used by: | ||
|
|
||
| - Your [app code](#using-sentry-auth-in-app-code) that needs to call the Sentry API | ||
| - Or, your [custom tools](#using-sentry-auth-in-custom-tools) that need to call the Sentry API | ||
|
|
||
| ## Configuring Sentry auth | ||
|
|
||
| <Callout type="info"> | ||
| When using your own app credentials, make sure you configure your project to | ||
| use a [custom user | ||
| verifier](/guides/user-facing-agents/secure-auth-production#build-a-custom-user-verifier). | ||
| Without this, your end-users will not be able to use your app or agent in | ||
| production. | ||
| </Callout> | ||
|
|
||
| In a production environment, you will most likely want to use your own Sentry app credentials. This way, your users will see your application's name requesting permission. | ||
|
|
||
| Before showing how to configure your Sentry app credentials, let's go through the steps to create a Sentry OAuth application. | ||
|
|
||
| ### Create a Sentry OAuth application | ||
|
|
||
| - Sign in to Sentry and open [Settings → Account → API → Applications](https://sentry.io/settings/account/api/applications/). | ||
| - Click **Create New Application**. | ||
| - Give the application a name. | ||
| - Add the **Authorized Redirect URI** generated by Arcade (see below). | ||
| - Save the application, then copy its **Client ID** and **Client Secret**. | ||
|
|
||
| Sentry requests scopes at authorization time rather than on the application itself. Choose the scopes your app or tools need when you call `auth.start()` (see the examples below). Common read scopes include: | ||
|
|
||
| - `org:read` | ||
| - `project:read` | ||
| - `team:read` | ||
| - `member:read` | ||
| - `event:read` | ||
|
|
||
| See Sentry's [permissions and scopes](https://docs.sentry.io/api/permissions/) reference for the full list. | ||
|
|
||
| Next, add the Sentry app to Arcade. | ||
|
|
||
| ## Configuring your own Sentry Auth Provider in Arcade | ||
|
|
||
| <Tabs items={["Dashboard GUI"]}> | ||
| <Tabs.Tab> | ||
|
|
||
| ### Configure Sentry Auth Using the Arcade Dashboard GUI | ||
|
|
||
| <Steps> | ||
|
|
||
| #### Access the Arcade Dashboard | ||
|
|
||
| To access the Arcade Cloud dashboard, go to [api.arcade.dev/dashboard](https://api.arcade.dev/dashboard). If you are self-hosting, by default the dashboard will be available at http://localhost:9099/dashboard. Adjust the host and port number to match your environment. | ||
|
|
||
| #### Navigate to the OAuth Providers page | ||
|
|
||
| - Under the **Connections** section of the Arcade Dashboard left-side menu, click **Connected Apps**. | ||
| - Click **Add OAuth Provider** in the top right corner. | ||
| - Select the **Included Providers** tab at the top. | ||
| - In the **Provider** dropdown, select **Sentry**. | ||
|
|
||
| #### Enter the provider details | ||
|
|
||
| - Choose a unique **ID** for your provider (e.g. "my-sentry-provider"). | ||
| - Optionally enter a **Description**. | ||
| - Enter the **Client ID** and **Client Secret** from your Sentry application. | ||
| - Note the **Redirect URL** generated by Arcade. This must be added to your Sentry application's Authorized Redirect URIs. | ||
|
|
||
| #### Create the provider | ||
|
|
||
| Hit the **Create** button and the provider will be ready to be used. | ||
|
|
||
| </Steps> | ||
|
|
||
| When you use tools that require Sentry auth using your Arcade account credentials, Arcade will automatically use this Sentry OAuth provider. If you have multiple Sentry providers, see [using multiple auth providers of the same type](/references/auth-providers#using-multiple-providers-of-the-same-type) for more information. | ||
|
|
||
| </Tabs.Tab> | ||
| </Tabs> | ||
|
|
||
| ## Using Sentry auth in app code | ||
|
|
||
| Use the Sentry auth provider in your own agents and AI apps to get a user token for the Sentry API. See [authorizing agents with Arcade](/get-started/about-arcade) to understand how this works. | ||
|
|
||
| Use `client.auth.start()` to get a user token for the Sentry API: | ||
|
|
||
| <Tabs items={["Python", "JavaScript"]} storageKey="preferredLanguage"> | ||
| <Tabs.Tab> | ||
|
|
||
| ```python {8-12} | ||
| from arcadepy import Arcade | ||
|
|
||
| client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable | ||
|
|
||
| user_id = "{arcade_user_id}" | ||
|
|
||
| # Start the authorization process | ||
| auth_response = client.auth.start( | ||
| user_id=user_id, | ||
| provider="sentry", | ||
| scopes=["org:read", "project:read"], | ||
| ) | ||
|
|
||
| if auth_response.status != "completed": | ||
| print("Please complete the authorization challenge in your browser:") | ||
| print(auth_response.url) | ||
|
|
||
| # Wait for the authorization to complete | ||
| auth_response = client.auth.wait_for_completion(auth_response) | ||
|
|
||
| token = auth_response.context.token | ||
| # Do something interesting with the token... | ||
| ``` | ||
|
|
||
| </Tabs.Tab> | ||
|
|
||
| <Tabs.Tab> | ||
|
|
||
| ```javascript {8-10} | ||
| import { Arcade } from "@arcadeai/arcadejs"; | ||
|
|
||
| const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable | ||
|
|
||
| const userId = "{arcade_user_id}"; | ||
|
|
||
| // Start the authorization process | ||
| let authResponse = await client.auth.start(userId, "sentry", { | ||
| scopes: ["org:read", "project:read"], | ||
| }); | ||
|
|
||
| if (authResponse.status !== "completed") { | ||
| console.log("Please complete the authorization challenge in your browser:"); | ||
| console.log(authResponse.url); | ||
| } | ||
|
|
||
| // Wait for the authorization to complete | ||
| authResponse = await client.auth.waitForCompletion(authResponse); | ||
|
|
||
| const token = authResponse.context.token; | ||
| // Do something interesting with the token... | ||
| ``` | ||
|
|
||
| </Tabs.Tab> | ||
|
|
||
| </Tabs> | ||
|
|
||
| ## Using Sentry auth in custom tools | ||
|
|
||
| You can author your own [custom tools](/guides/create-tools/tool-basics/build-mcp-server) that interact with the Sentry API. | ||
|
|
||
| Use the `Sentry()` auth class to specify that a tool requires authorization with Sentry. The `context.authorization.token` field will be automatically populated with the user's Sentry token: | ||
|
|
||
| ```python {5-6,9-13,21} | ||
| from typing import Annotated | ||
|
|
||
| import httpx | ||
|
|
||
| from arcade_tdk import ToolContext, tool | ||
| from arcade_tdk.auth import Sentry | ||
|
|
||
|
|
||
| @tool( | ||
| requires_auth=Sentry( | ||
| scopes=["org:read"], | ||
| ) | ||
| ) | ||
| async def list_organizations( | ||
| context: ToolContext, | ||
| ) -> Annotated[list[dict], "The organizations the user can access"]: | ||
| """List the Sentry organizations the authorized user belongs to.""" | ||
| url = "https://sentry.io/api/0/organizations/" | ||
| headers = {"Authorization": f"Bearer {context.authorization.token}"} | ||
|
|
||
| async with httpx.AsyncClient() as client: | ||
| response = await client.get(url, headers=headers) | ||
| response.raise_for_status() | ||
| return response.json() | ||
| ``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouln't this come from Design System?