Atmosphere® API Authentication

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

Tokens are placed in the HTTP header as follows:
Authorization: Bearer TOKEN_PROVIDED_BY_INTELEPEER

Acquiring a Token

Tokens can be acquired in one of two ways:

  • Best for Production Applications: Through the Atmosphere® API using your assigned Username and Password. The IntelePeer-assigned username and password are your IntelePeer Customer Portal login credentials.
  • Best for Getting Used to the API: Through the IntelePeer Customer Portal.

Note: During your 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 that initial token, subsequent tokens can be acquired through the Atmosphere ® API.


Acquiring a Token through the Customer Portal

Navigate to the SMS Application under My Applications.

 

Click the Settings button.

 

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

Note: During your 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 that initial token, subsequent tokens can be acquired through the Atmosphere ® API.

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

The recommended process for acquiring and using Authentication tokens in your production environment is:

  1. Application configuration: Store Atmosphere® API Username and Password in secure configuration location.
  2. On application start up: Retrieve token from Atmosphere® API using Username and Password, and store token in memory for subsequent API calls.
  3. For each API call: Utilize the previously-retrieved token.
  4. Upon Expiration (End of 24 Hours or Receiving HTTP 401 response on API call): Retrieve new token from Atmosphere® API.

 

URI

POST to https://api.intelepeer.com/sms/v1/authenticate/get_portal_auth_token

 

Parameters
ParameterData TypeRequiredDescription
usernamestringrequiredIntelePeer-assigned username
passwordstringrequiredPassword associated with the username

 

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

 

Response Codes
Response CodeDescription
200Successful authentication. Token returned in the body of the response.
401One 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"
}

 

Example Code

Java

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<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
		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());
    }
}

 

Node.js

const request = require("request");
///////////////////////////////////////////////////////////////////////////////
/// update these accordingly                                                ///
///////////////////////////////////////////////////////////////////////////////
let data = { "username": "INSERT_USERNAME", "password": "INSERT_PASSWORD" }

///////////////////////////////////////////////////////////////////////////////
/// leave these alone                                                       ///
///////////////////////////////////////////////////////////////////////////////
let url  = "https://api.intelepeer.com/sms/v1/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);
});

 

PHP

<?php

require '../vendor/autoload.php';
use GuzzleHttp\Client;

###############################################################################
### update these accordingly                                                ###
###############################################################################
$data = ["username" => "INSERT_USERNAME", "password" => "INSERT_PASSWORD" ];

###############################################################################
### leave these alone                                                       ###
###############################################################################
$url  = "https://api.intelepeer.com/sms/v1/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();
?>

 

Python

import requests

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

###############################################################################
### leave these alone                                                       ###
###############################################################################
url  = "https://api.intelepeer.com/sms/v1/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 )