Auth0-PHP

GeneratorInterface
in

Table of Contents

Methods

__toString()  : string
Generate a new token and return it as a string.
create()  : static
Create a new token generator instance.
toArray()  : array<string|int, mixed>
Generate a new token and return it as an array.
toString()  : string
Generate a new token and return it as a string.

Methods

create()

Create a new token generator instance.

public static create(OpenSSLAsymmetricKey|string $signingKey[, string $algorithm = Token::ALGO_RS256 ][, array<string|int, mixed> $claims = [] ][, array<string|int, string> $headers = [] ][, null|string $signingKeyPassphrase = null ]) : static
Parameters
$signingKey : OpenSSLAsymmetricKey|string

Signing key to use for signing the token. This MUST be a string for HS256. MUST be either a string or OpenSSLAsymmetricKey for RS256.

$algorithm : string = Token::ALGO_RS256

Algorithm to use for signing the token. Defaults to RS256.

$claims : array<string|int, mixed> = []

Claims to include in the token. Defaults to an empty array.

$headers : array<string|int, string> = []

Headers to include in the token. Defaults to an empty array. The the "alg" header will be set to represent $algorithm appropriately.

$signingKeyPassphrase : null|string = null

Optional. Passphrase to use for signing key if it is encrypted. Defaults to null.

Tags
throws
TokenException

When an unsupported algorithm is provided.

TokenException

When a non-string $signingKey is provided for HS256.

TokenException

When a string $signingKey is used with RS256.

TokenException

When using RS256 and openssl_pkey_get_private() is unable to load the provided signing key.

Return values
static

toArray()

Generate a new token and return it as an array.

public toArray([bool $encodeSegments = true ]) : array<string|int, mixed>
Parameters
$encodeSegments : bool = true

Whether to encode the segments or not. Defaults to true.

Tags
throws
TokenException

If an error occurs while generating the token.

Return values
array<string|int, mixed>
On this page

Search results