-
Notifications
You must be signed in to change notification settings - Fork 521
/
Copy pathorgs_api.js
37 lines (32 loc) · 883 Bytes
/
orgs_api.js
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
"use strict";
var Twilio = require("../lib");
const clientId = process.env.ORGS_CLIENT_ID;
const clientSecret = process.env.ORGS_CLIENT_SECRET;
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const organizationSid = process.env.TWILIO_ORG_SID;
const orgsCredentialProvider = new Twilio.OrgsCredentialProviderBuilder()
.setClientId(clientId)
.setClientSecret(clientSecret)
.build();
const client = new Twilio();
client.setCredentialProvider(orgsCredentialProvider);
client.setAccountSid(accountSid);
client.previewIam
.organization(organizationSid)
.accounts.list()
.then((accounts) => {
console.log(accounts);
})
.catch((error) => {
console.log(error);
});
client.previewIam
.organization(organizationSid)
.accounts(accountSid)
.fetch()
.then((account) => {
console.log(account);
})
.catch((error) => {
console.log(error);
});