Working with auth tokens from PHP SDK
PHP SDK offers you a way to handle auth tokens from the backend of your system.
Auth tokens allow you to add additional layer of security to your videos. While we offer a way to do this through dashboard, bellow you will see how you can do that and even more through the API calls.
PHP SDK Authtoken Methods
- get Get a single auth token by token.
$ziggeo->authtokens()->get($token)
This method returns JSONExample:<?php /* This script will show you how to get auth token details docs: https://ziggeo.com/docs/api/authorization-tokens/ Parameters you need to pass: 1. app_token 2. private_key 3. auth_token */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); $opts = getopt("", array("app_token:", "private_key:","auth_token:")); $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]); $result = $ziggeo->authtokens()->get($opts["auth_token"]); var_dump($result); ?>
- update Update single auth token by token.
$ziggeo->authtokens()->update($token_or_key, $arguments = array())
- volatile Will this object automatically be deleted if it remains empty?
- hidden If hidden, the token cannot be used directly.
- expiration_date Expiration date for the auth token (Unix epoch time format)
- usage_expiration_time Expiration time per session (seconds)
- session_limit Maximal number of sessions
- grants Permissions this tokens grants
This method returns JSONExample:<?php /* This script will show you how to update existing server side auth token docs: https://ziggeo.com/docs/api/authorization-tokens/ Parameters you need to pass: 1. app_token 2. private_key 3. auth_token */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); $opts = getopt("", array("app_token:", "private_key:","auth_token:")); $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]); $result = $ziggeo->authtokens()->update($opts["auth_token"] ,array( "grants" => array( "read" => array( "session_owned" => TRUE ) ), "usage_expiration_time" => 86400, "session_limit" => 2 )); var_dump($result); ?>
- delete Delete a single auth token by token.
$ziggeo->authtokens()->delete($token_or_key)
Example:<?php /* This script will show you how to delete auth token docs: https://ziggeo.com/docs/api/authorization-tokens/ Parameters you need to pass: 1. app_token 2. private_key 3. auth_token */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); $opts = getopt("", array("app_token:", "private_key:","auth_token:")); //We initialize our SDK $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]); $result = $ziggeo->authtokens()->delete($opts["auth_token"]); var_dump($result); ?>
- create Create a new auth token.
$ziggeo->authtokens()->create($arguments = array())
- volatile Will this object automatically be deleted if it remains empty?
- hidden If hidden, the token cannot be used directly.
- expiration_date Expiration date for the auth token (Unix epoch time format)
- usage_expiration_time Expiration time per session (seconds)
- session_limit Maximal number of sessions
- grants Permissions this tokens grants
This method returns JSONExample:<?php /* This script will show you how to create server side auth tokens docs: https://ziggeo.com/docs/api/authorization-tokens/ Parameters you need to pass: 1. app_token 2. private_key */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); $opts = getopt("", array("app_token:", "private_key:")); //We initialize our SDK $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]); $result = $ziggeo->authtokens()->create(array( "grants" => array( "read" => array( "all" => TRUE ) ) )); var_dump($result); ?>
PHP SDK Auth Methods
- generate Creates the encrypted auth token object that you can pass to your recorder
$ziggeo->auth()->generate($arguments = array())
- volatile Will this object automatically be deleted if it remains empty?
- hidden If hidden, the token cannot be used directly.
- expiration_date Expiration date for the auth token (Unix epoch time format)
- usage_expiration_time Expiration time per session (seconds)
- session_limit Maximal number of sessions
- grants Permissions this tokens grants
This method returns stringExample:<?php /* This script will allow you to see how to create client side auth tokens docs: https://ziggeo.com/docs/api/authorization-tokens/ Parameters you need to pass: 1. app_token 2. private_key 3. encryption_key */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); $opts = getopt("", array("app_token:", "private_key:", "encryption_key:")); //We initialize our SDK $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"], $opts["encryption_key"]); $result = $ziggeo->auth()->generate(array( "grants" => array( "read" => array( "all" => TRUE ) ) )); var_dump($result); ?>