Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created March 17, 2023 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendbird-community/e2d5f9057473b5fde6e16807551af383 to your computer and use it in GitHub Desktop.
Save sendbird-community/e2d5f9057473b5fde6e16807551af383 to your computer and use it in GitHub Desktop.
getAgentsSendbirdCreds: function (user) {
//Installation parameters protect Sendbird's API tokn - https://developers.freshdesk.com/v2/docs/installation-parameters/
//Headers here use templating to pick up the iparam.api_token - https://developers.freshdesk.com/v2/docs/request-method/#sample_requests
//See iparam.json for the settings
//Here the api-token is hard coded - don't use this approach in production.
$request.get(`https://api-${APP_ID}.sendbird.com/v3/users/${user.sendbirdUserId}` , {headers})
.then(
function (data) {
//handle "data"
//"data" is a json string with status, headers, and response.
renderData(null, data)
},
function (error) {
// var error = { status: 403, message: "Error while processing the request" };
renderData({message: JSON.stringify(error)});
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment