PHP code example of giftuals / tokenizer

1. Go to this page and download the library: Download giftuals/tokenizer 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/ */

    

giftuals / tokenizer example snippets


$config = new Tokenizer\Config\Config([
    Tokenizer\Tokenizer::HASH_HMAC_KEY => 'some-uber-secret-key',
    Tokenizer\Tokenizer::CLAIM_ISSUER => 'Giftuals',
    Tokenizer\Tokenizer::CLAIM_SUBJECT => 'Example token',
    Tokenizer\Tokenizer::CLAIM_AUDIENCE => 'https://backend.giftuals.com',
]);
$tokenizer = new Tokenizer\Tokenizer($config);
$jwt = $tokenizer->createToken([
    'my_own_claim' => 'some random value',
]);
try {
    $tokenizer->isValidToken($jwt);
    $payload = $tokenizer->getTokenPayload($jwt);
} catch (Tokenizer\Exception\InvalidTokenException $e) {
    // Something went wrong
}