forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclients.ts
More file actions
39 lines (33 loc) · 1.02 KB
/
Copy pathclients.ts
File metadata and controls
39 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Usage:
// From examples/node, run files with "npm test ./src/clients.ts"
import clerk, { clients } from '@clerk/clerk-sdk-node';
const clientId = process.env.CLIENT_ID || '';
const sessionToken = process.env.SESSION_TOKEN || '';
console.log('Get client list');
const clientList = await clients.getClientList();
console.log(clientList);
console.log('Get single client');
const client = await clients.getClient(clientId);
console.log(client);
try {
console.log('Verify client');
const verifiedClient = await clients.verifyClient(sessionToken);
console.log(verifiedClient);
} catch (error) {
console.log(error);
}
try {
console.log('Get single client for invalid clientId');
const invalidClient = await clients.getClient('foobar');
console.log(invalidClient);
} catch (error) {
console.log(error);
}
try {
console.log('Get client list with invalid API key');
clerk.apiKey = 'snafu';
const invalidClients = await clerk.clients.getClientList();
console.log(invalidClients);
} catch (error) {
console.log(error);
}