-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add documentation for orgs API and public oauth (#1056)
- Loading branch information
1 parent
ad54ea7
commit 86744d5
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,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); | ||
}); |
This file contains 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,25 @@ | ||
var Twilio = require("../lib"); | ||
|
||
const clientId = process.env.OAUTH_CLIENT_ID; | ||
const clientSecret = process.env.OAUTH_CLIENT_SECRET; | ||
const accountSid = process.env.TWILIO_ACCOUNT_SID; | ||
|
||
const clientCredentialProvider = new Twilio.ClientCredentialProviderBuilder() | ||
.setClientId(clientId) | ||
.setClientSecret(clientSecret) | ||
.build(); | ||
|
||
const client = new Twilio(); | ||
client.setCredentialProvider(clientCredentialProvider); | ||
client.setAccountSid(accountSid); | ||
|
||
const messageId = "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; | ||
client | ||
.messages(messageId) | ||
.fetch() | ||
.then((message) => { | ||
console.log(message); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); |