Skip to content

Commit cb8a6f9

Browse files
committed
Finish writing Zendesk auth provider docs
1 parent 7f0cc68 commit cb8a6f9

5 files changed

Lines changed: 97 additions & 8 deletions

File tree

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ build: ## Build the docs site
1515

1616
run: ## Run the docs site locally
1717
@pnpm dev
18+
19+
ruin:
20+
@echo "\033[31m\033[1m💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️\033[0m"
21+
@echo "\033[31m\033[1m👻 👻\033[0m"
22+
@echo "\033[31m\033[1m🔥 With but a single command, the realm 🔥\033[0m"
23+
@echo "\033[31m\033[1m🔥 of order shall collapse into chaos. 🔥\033[0m"
24+
@echo "\033[31m\033[1m👻 👻\033[0m"
25+
@echo "\033[31m\033[1m⚡ Beware, for what is ruined today may ⚡\033[0m"
26+
@echo "\033[31m\033[1m⚡ take an eternity to rebuild. ⚡\033[0m"
27+
@echo "\033[31m\033[1m👻 👻\033[0m"
28+
@echo "\033[31m\033[1m🎃 - The Elders of Makefile 🎃\033[0m"
29+
@echo "\033[31m\033[1m👻 👻\033[0m"
30+
@echo "\033[31m\033[1m💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️💀☠️\033[0m"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
3+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
const userId = "{arcade_user_id}";
6+
7+
// Start the authorization process
8+
let authResponse = await client.auth.start(userId, {
9+
provider: "zendesk",
10+
scopes: ["read_account"],
11+
});
12+
13+
if (authResponse.status !== "completed") {
14+
console.log("Please complete the authorization challenge in your browser:");
15+
console.log(authResponse.url);
16+
}
17+
18+
// Wait for the authorization to complete
19+
authResponse = await client.auth.waitForCompletion(authResponse);
20+
21+
const token = authResponse.context.token;
22+
23+
// Do something interesting with the token...
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from arcadepy import Arcade
2+
3+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
# Start the authorization process
6+
auth_response = client.auth.start(
7+
user_id="{arcade_user_id}",
8+
provider="zendesk",
9+
scopes=["read_account"],
10+
)
11+
12+
if auth_response.status != "completed":
13+
print("Please complete the authorization challenge in your browser:")
14+
print(auth_response.url)
15+
16+
# Wait for the authorization to complete
17+
auth_response = client.auth.wait_for_completion(auth_response)
18+
19+
token = auth_response.context.token
20+
21+
# Do something interesting with the token...
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from typing import Annotated, Any
2+
3+
from arcade_tdk import ToolContext, tool
4+
from arcade_tdk.auth import OAuth2
5+
6+
import httpx
7+
8+
9+
@tool(
10+
requires_auth=OAuth2(id="zendesk", scopes=["read"]),
11+
requires_secrets=["ZENDESK_SUBDOMAIN"],
12+
)
13+
async def get_tickets(
14+
context: ToolContext
15+
) -> Annotated[dict[str, Any], "Recent tickets from Zendesk"]:
16+
"""Get recent tickets from Zendesk including basic ticket information"""
17+
token = context.get_auth_token_or_empty()
18+
subdomain = context.get_secret("ZENDESK_SUBDOMAIN")
19+
url = f"https://{subdomain}.zendesk.com/api/v2/tickets.json"
20+
headers = {
21+
"Authorization": f"Bearer {token}",
22+
"Content-Type": "application/json",
23+
"Accept": "application/json",
24+
}
25+
26+
async with httpx.AsyncClient() as client:
27+
resp = await client.get(url, headers=headers)
28+
resp.raise_for_status()
29+
data = resp.json()
30+
31+
return {"tickets": data}

pages/home/auth-providers/zendesk.mdx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ This page describes how to use and configure Zendesk auth with Arcade.
1717
This auth provider is used by:
1818

1919
- The [Arcade Zendesk toolkit](/toolkits/customer-support/zendesk), which provides pre-built tools for interacting with Zendesk services
20-
- Your [app code](#calling-zendesk-apis-directly) that needs to call Zendesk APIs
21-
- Or, your [custom tools](#create-your-own-zendesk-tools) that need to call Zendesk APIs
20+
- Your [app code](#using-zendesk-auth-in-app-code) that needs to call Zendesk APIs
21+
- Or, your [custom tools](#using-zendesk-auth-in-custom-tools) that need to call Zendesk APIs
2222

2323
## Create a Zendesk app
2424

25-
To create a Zendesk app, there are two important guides from Zendesk that you can follow:
25+
### Additional guides
26+
The following two guides from Zendesk will be helpful additional information as you progress through this guide:
2627
1. [Using OAuth authentication with your application](https://support.zendesk.com/hc/en-us/articles/4408845965210-Using-OAuth-authentication-with-your-application)
2728
2. [Set up a global OAuth client](https://developer.zendesk.com/documentation/marketplace/building-a-marketplace-app/set-up-a-global-oauth-client/)
2829

29-
For a more streamlined set of instructions, follow the steps below:
30+
### Creating a Zendesk app for Arcade
3031
1. Create your Organization in the [Zendesk Marketplace portal](https://apps.zendesk.com/).
3132
1. Create a Zendesk support account at https://www.zendesk.com/login . If you need a global OAuth client, then the subdomain MUST begin with "d3v-". You will need a global OAuth client if your app will use integrations/tools for multiple customers with their own Zendesk instances (multiple subdomains).
3233
1. In [the Admin Center](https://support.zendesk.com/hc/en-us/articles/4581766374554#topic_hfg_dyz_1hb), click "Apps and integrations" in the sidebar, then select APIs > OAuth clients > Add OAuth client.
@@ -156,15 +157,15 @@ Use `client.auth.start()` to get a user token for Zendesk APIs:
156157
<Tabs items={["Python", "JavaScript"]} storageKey="preferredLanguage">
157158
<Tabs.Tab>
158159

159-
```python file=<rootDir>/examples/code/integrations/zendesk/custom_auth.py {8-12}
160+
```python file=<rootDir>/examples/code/integrations/zendesk/custom_auth.py {6-10}
160161

161162
```
162163

163164
</Tabs.Tab>
164165

165166
<Tabs.Tab>
166167

167-
```javascript file=<rootDir>/examples/code/integrations/zendesk/custom_auth.js {8-10}
168+
```javascript file=<rootDir>/examples/code/integrations/zendesk/custom_auth.js {8-11}
168169

169170
```
170171

@@ -174,10 +175,10 @@ Use `client.auth.start()` to get a user token for Zendesk APIs:
174175

175176
## Using Zendesk auth in custom tools
176177

177-
You can author your own [custom tools](/home/build-tools/create-a-toolkit) that interact with Zendesk APIs.
178+
If the [Arcade Zendesk toolkit](/toolkits/customer-support/zendesk) does not meet your needs, you can author your own [custom tools](/home/build-tools/create-a-toolkit) that interact with Zendesk APIs.
178179

179180
Use the `OAuth2()` auth class to specify that a tool requires authorization with Zendesk. The `context.authorization.token` field will be automatically populated with the user's Zendesk token:
180181

181-
```python file=<rootDir>/examples/code/integrations/zendesk/custom_tool.py {5-6,9-13,20}
182+
```python file=<rootDir>/examples/code/integrations/zendesk/custom_tool.py
182183

183184
```

0 commit comments

Comments
 (0)