public function TokenGenerator::generate in Auth0 Single Sign On 8.2
Create the ID token.
Parameters
array $scopes Array of scopes to include.:
integer $lifetime Lifetime of the token, in seconds.:
boolean $secret_encoded True to base64 decode the client secret.:
Return value
string
File
- vendor/
auth0/ auth0-php/ src/ API/ Helpers/ TokenGenerator.php, line 56
Class
- TokenGenerator
- Class TokenGenerator. Generates HS256 ID tokens.
Namespace
Auth0\SDK\API\HelpersCode
public function generate(array $scopes, $lifetime = self::DEFAULT_LIFETIME, $secret_encoded = true) {
$time = time();
$payload = [
'iat' => $time,
'scopes' => $scopes,
'exp' => $time + $lifetime,
'aud' => $this->audience,
];
$payload['jti'] = md5(json_encode($payload));
$secret = $secret_encoded ? base64_decode(strtr($this->secret, '-_', '+/')) : $this->secret;
return JWT::encode($payload, $secret);
}