XMF Cookbook
  • Introduction
  • XMF Cookbook
  • Basic Ingredients
    • Namespaces
    • Autoloading
    • Debugging
    • Forward Compatibility
  • Recipes
    • Introducing Module Helpers
    • Using the Permission Helper
      • Checking Permissions
      • Managing Item Permissions
    • Using the Session Helper
    • Using JSON Web Tokens
    • Altering Database Tables
    • Migrating a Module's Database
    • Loading Initial Data
    • Module Admin Pages
      • Hide and Seek with Icons
      • Standard Admin Pages
    • Manage Metadata
    • Highlighting Content
  • Reference
    • Assert
      • Assertions
    • Database
      • Migrate
      • TableLoad
      • Tables
        • Getting Started
        • Table Operations
        • Working with Columns
        • Working with Indexes
        • Changing Table Data
        • Interacting with the Work Queue
        • Error Info and Debugging
    • Debug
    • FilterInput
    • Highlighter
    • IPAddress
    • Jwt
      • JsonWebToken
      • KeyFactory
      • TokenFactory
      • TokenReader
    • Key
      • ArrayStorage
      • Basic
      • FileStorage
      • KeyAbstract
      • StorageInterface
    • Language
    • Metagen
      • Extracting Data
      • Applying Data
    • Module
      • Admin
      • Helper
      • Helper
        • AbstractHelper
        • Cache
        • GenericHelper
        • Permission
        • Session
    • ProxyCheck
    • Random
    • Request
    • StopWords
    • Uuid
    • Yaml
  • Credits
  • License:
  • Table of Content
Powered by GitBook
On this page
  1. Reference
  2. Jwt

TokenFactory

PreviousKeyFactoryNextTokenReader

Last updated 6 years ago

The Xmf\Jwt\TokenFactory class provides a convenient factory method to simplify creating JSON Web Token strings.

TokenFactory::build($key, $payload, $expirationOffset)

This method creates and returns a JSON Web Token string.

The $key is used to to sign the token. It may be specified as a object, or a key name string that will be used to build a key object using the using a default instance for storage.

The $payload is an associative array of claims included in the token, elements in the form claim => value.

The $expirationOffset is an integer that specifies an expiration time as the number of seconds from now that the token will expire. If specified, this will be added as an 'exp' claim to the payload.

If the token cannot be generated, an exception will be thrown. Possible exceptions include:

  • DomainException;

  • InvalidArgumentException;

  • UnexpectedValueException;

KeyAbstract
KeyFactory
FileStorage