Skip to content

Instantly share code, notes, and snippets.

@dtolb
Created May 18, 2016 17:33
Show Gist options
  • Select an option

  • Save dtolb/db45e19201812c232f6d7022a59229dd to your computer and use it in GitHub Desktop.

Select an option

Save dtolb/db45e19201812c232f6d7022a59229dd to your computer and use it in GitHub Desktop.
Token

Making and receiving a call in the browser is done through a Bandwidth JavaScript library called BWClient. Using the BWClient library you will login for a given user/endpoint (e.g. webuser1 with password abc123 from above). For security reasons, you do not want the password exposed in the JavaScript code running in the browser.

Therefore, you will obtain an authorization token in your App Server and use that token to login.

To create an authorization token, use the following REST API:

POST /v1/users/<user-id>/domains/<domain-id>/endpoints/<endpoint-id>/tokens

returns

Headers:
Location <host>/v1/users/<user-id>/domains/<domain-id>/endpoints/<endpoint-id>/tokens/<token>
201 Created. Token information in a JSON payload.
{
   “expires” : 86400,
   “token”: “283ha89bva289fajf2093jf”
}

where expires is the duration of the token in seconds and token is the authorization token to be passed to the BWClient JavaScript library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment