PHP code example of zacharyrankin / hmac-auth

1. Go to this page and download the library: Download zacharyrankin/hmac-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zacharyrankin / hmac-auth example snippets


use zacharyrankin\hmac_auth\Authenticator;
use zacharyrankin\hmac_auth\Client;

$auth = new Authenticator;
$token = $auth->createToken(new Client('some user', 'user secret'));
header('X-Authorization-Token: ' . $token);

use zacharyrankin\hmac_auth\Authenticator;
use zacharyrankin\hmac_auth\Client;

$auth = new Authenticator
$auth->authenticate(
  $_SERVER['HTTP_X_AUTHORIZATION_TOKEN'],
  function ($clientId) {
    return new Client($clientId, SomeModel::findSecret($clientId));
  },
  300 // expiration in seconds
);