Automated Voximplant SDK login

Automated Voximplant SDK login

There are some cases when you need to login users into a web phone automatically, but don't want plain text password (that is accepted by VoxImplant.getInstance().login()) to be available in JavaScript code.

We have a solution for this problem. Let's assume that you need to log in a user named myuser to application myapp in your Voximplant account named myaccount, and that user has password mypass.

  1. Add a handler for the AuthResult event.
  2. Request one-time authentication login key using the requestOneTimeLoginKey function.
  3. Calculate token on your backend

    PLEASE NOTICE that myuser doesn’t include 

  4. Send this token using the loginWithOneTimeKey function
  5. Finally, you should receive AuthResult with result == true if the correct password was specified.


// app.js on client
// Please, change this data before go.
const appUser = 'APPLICATIONUSER';
const appUserPassword = 'SECUREPASSWORD';
const appName = 'VOXAPPLICATION';
const account = 'ACCOUNT';
const URI = `${appUser}@${appName}.${account}`;

const voximplant = VoxImplant.getInstance();
// Connect to the cloud and request a key
voximplant.connect().then(() => voximplant.requestOneTimeLoginKey(URI));

// Listen to the server response
voximplant.addEventListener(VoxImplant.Events.AuthResult, e => {
  console.log(`AuthResult: ${e.result}`);
  console.log(`Auth code: ${e.code}`);
  if (e.result) {
    // Login is successful
  } else if (e.code == 302) {
    // IMPORTANT: You should always calculate the token on your backend!
    $.post('', {
      key: e.key,
      appUser: appUser,
      appUserPassword: appUserPassword
    }, token => {
      voximplant.loginWithOneTimeKey(URI, token);
    }, 'text');


Example backend function PHP:

echo md5($_REQUEST['key'].'|'.md5($myuser.''.$mypass));



require 'digest/md5' concat Digest::MD5.hexdigest(request.POST['key']+'|'+Digest::MD5.hexdigest(myuser+""+mypass))



const app = express();

let md5 = crypto.createHash('md5');

app.use(bodyParser.urlencoded({ extended: false }));'/', cors(), (req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  const hash = md5.update(`${req.body.appUser}${req.body.appUserPassword}`).digest('hex');
  md5 = crypto.createHash('md5')
  const token = md5.update(`${req.body.key}\|${hash}`).digest('hex');



public class StartPoint {
  private static final String login = "";
  private static final String pass = "";
  private static final String HASH;
  static {
    HASH = DigestUtils.md5DigestAsHex((login + "" + pass).getBytes());
  public String getHash(@PathVariable String login) {
    String key = login + "|" + HASH;
    return DigestUtils.md5DigestAsHex(key.getBytes());
  public static void main(String[] args) {, args);
Tags:ios sdkweb sdkandroid sdk
B6A24216-9891-45D1-9D1D-E7359CEB8282 Created with sketchtool.


Add your comment

Please complete this field.


Sign up for a free Voximplant developer account or talk to our experts