Generate token with NodeJS
In this article, we will explain how you can generate a Sonetel access token with NodeJS and how you can use it to interact with our API.
To get started, ensure that you have a free Sonetel account. You will have to use your username and password to acquire an access token.
Once that is done get the sample code from GitHub.
The code is a NodeJS module that exports a function called
createAccessToken. This function can be used to generate an OAuth access token for a Sonetel account, using the Sonetel API.
createAccessToken function accepts two arguments:
username: The email address used to sign in at sonetel.com.
password: The login password for the Sonetel account.
The function first checks that the
password arguments are provided. It then constructs an HTTP request to the Sonetel API, using the
POST method, the
password parameters, and basic authentication with the
sonetel-api username and password. The request is sent and the response is handled asynchronously, extracting the access token and resolving it as a Promise.
You can find the full API-documentation here.