Skip to main content

Token authentication

This example is written for the Canistracci OIL tenant. Create the objects with a Docs Demo prefix, test them on non-production numbers, and then adapt the same structure for the production tenant.

If you like to integrate MiRTA PBX in your portal and you like to have a single authentication, you can create a token with the username and password for the user and pass to the the related application page script.

<?php

$key='*******';

$credentials['username']='*****';

$credentials['password']='*****';

$keyHash = hash('sha256', $key, true);

$iv = substr($keyHash, 0, 16);

define('AES_256_CBC', 'aes-256-cbc');

$token=base64_encode(openssl_encrypt(json_encode($credentials), AES_256_CBC, $keyHash, OPENSSL_RAW_DATA, $iv));

$decoded=openssl_decrypt(base64_decode($token),AES_256_CBC,$keyHash,OPENSSL_RAW_DATA, $iv);

error_log($token);

error_log($decoded);

?>

The generated token can be passed to the the related application page via GET or POST as parameter token

the PBX web address related application page

Canistracci OIL example screen for Token authentication.
Canistracci OIL example screen for Token authentication.

Validation

  • Confirm the tenant selected in the top bar is Canistracci OIL before creating the example.
  • Verify the created objects appear in the expected Configuration menu page.
  • Place a controlled test call or run the related status check.
  • Remove or disable temporary test numbers when the example is no longer needed.