Atmosphere® API Authentication

The Atmosphere® API uses a token in the HTTP header to authenticate users and requests.

 

  • Put tokens are in the HTTP header as follows:
    Authorization: TOKEN_PROVIDED_BY_INTELEPEER

    Acquiring a Token
    Get a tokens in one of two ways.

 

  • Best for production applications: Through the Atmosphere® API using your assigned username and password which are your IntelePeer Customer Portal login credentials.

 

  • Best for getting used to the API: Through the IntelePeer Customer Portal.
    Note: During initial account set up, you must get your credentials for the API authentication token from the SMS Management application on the IntelePeer Customer Portal. Once you have acquired the initial token, subsequent tokens can be acquired through the Atmosphere ® API.
 

Acquiring a Token through the Customer Portal

In My Applications, click SMS Application.

 

Click Settings.

 

Click GET KEY and select the time period for which you would like the key to be valid.

 

A valid API Key is displayed and can be used in API calls for your account.

 


Acquiring a Token through the API

Tokens acquired directly through the Atmosphere® API are valid for 24 hours.

 

Follow this process for acquiring and using authentication tokens in your production environment. 

 

  1. Store the Atmosphere® API username and password in a secure configuration location.
  2. On application startup, retrieve the token from the Atmosphere® API using and store it in memory for subsequent API calls.
  3. For each API call use the previously retrieved token.
  4. Once the token expires after 24 Hours or receipt of an HTTP 401 response on an API call,  get a  new token from Atmosphere® API.

 
URI

POST to https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token

 
Parameters

 

ParameterData TypeRequiredDescription

username

 

 

 

stringrequiredIntelePeer-assigned username which has SMS API access
passwordstringrequiredPassword associated with the username

 

Note: Verify that the number you are authenticating is a user account role that is enabled for SMS.

 
Request Example

{
    "username": "sms_user",
    "password": "Password123",
}

 
Response Codes

 

Response CodeDescription
200

Successful authentication. Token returned in the body of the response.

 

401

One of the following errors occurred:

  • Unable to validate credentials
  • A required parameter is missing
  • SMS is not enabled on the account

 
Response Example

{
    "token": "TOKEN_RETURNED_BY_API_FOR_SUBSEQUENT_CALLS",
    "expires": "2019-03-08 03:41:11"
}

package main.java.authorization;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;

public class GetToken {
    public static void main(String... args) throws Exception {
        final String url = "https://api.intelepeer.com/sms/v1/authenticate/get_portal_auth_token";
        final String USERNAME = "INSERT_USERNAME";
        final String PASSWORD = "INSERT_PASSWORD";

        HttpClient httpclient = HttpClientBuilder.create().build();
        HttpPost httpPost = new HttpPost(url);

        // add header
        httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");

        // Data to be posted
        List urlParameters = new ArrayList();
        urlParameters.add(new BasicNameValuePair("username", USERNAME));
        urlParameters.add(new BasicNameValuePair("password", PASSWORD));

        // add data to post
        httpPost.setEntity(new UrlEncodedFormEntity(urlParameters));

        // execute post
        HttpResponse response = httpclient.execute(httpPost);

        // show post results
        System.out.println("nSending 'POST' request to URL : " + url);
        System.out.println("Post parameters : " + httpPost.getEntity());
        System.out.println("Response Code : " +
                                    response.getStatusLine().getStatusCode());

        BufferedReader rd = new BufferedReader(
                        new InputStreamReader(response.getEntity().getContent()));

        StringBuffer result = new StringBuffer();
        String line = "";
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }

        System.out.println(result.toString());
    }
}
const request = require("request");
///////////////////////////////////////////////////////////////////////////////
/// update these accordingly                                                ///
///////////////////////////////////////////////////////////////////////////////
let data = { "username": "INSERT_USERNAME", "password": "INSERT_PASSWORD" }

///////////////////////////////////////////////////////////////////////////////
/// leave these alone                                                       ///
///////////////////////////////////////////////////////////////////////////////
let url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token"
let hdrs = {  'Content-Type': "application/json" }

///////////////////////////////////////////////////////////////////////////////
/// execute the task and parse results                                      ///
///////////////////////////////////////////////////////////////////////////////
request.get({
        url: url,
        headers: hdrs
    },
    (error, response, body) => {               
        let result = JSON.parse(body);
        console.log(result.token);
});
 "INSERT_USERNAME", "password" => "INSERT_PASSWORD" ];

###############################################################################
### leave these alone                                                       ###
###############################################################################
$url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token";
$hdrs = ['Content-Type' => "application/json" ];

###############################################################################
### execute the task and parse results                                      ###
###############################################################################

try{
  $client = new Client();
  $response = $client->post($url, [
    'headers' => $hdrs,
    'json' => $data
    ]);
}
catch (RequestException $e){
  echo "Request Failed:". $e->getMessage();
}

echo $response->getBody();
?>
import requests

###############################################################################
### update these accordingly                                                ###
###############################################################################
data = { "username": "INSERT_USERNAME", "password": "INSERT_PASSWORD" }

###############################################################################
### leave these alone                                                       ###
###############################################################################
url  = "https://api.intelepeer.com/_rest/v4/app/sms/authenticate/get_portal_auth_token"
hdrs = {  'Content-Type': "application/json" }

###############################################################################
### execute the task and parse results                                      ###
###############################################################################
response    = requests.post(url, json=data, headers=hdrs)
status_code = response.status_code
text        = response.text
token = None
try:
    token = response.json().get(u'token')
except: pass

print u'{}: {}'.format('OK' if response else 'ERROR', response.text )