You are here

public function JwtAuth::generateToken in JSON Web Token Authentication (JWT) 8

Same name and namespace in other branches
  1. 8.0 src/Authentication/Provider/JwtAuth.php \Drupal\jwt\Authentication\Provider\JwtAuth::generateToken()

Generate a new JWT token calling all event handlers.

Return value

string|bool The encoded JWT token. False if there is a problem encoding.

File

src/Authentication/Provider/JwtAuth.php, line 96

Class

JwtAuth
JWT Authentication Provider.

Namespace

Drupal\jwt\Authentication\Provider

Code

public function generateToken() {
  $event = new JwtAuthGenerateEvent(new JsonWebToken());
  $this->eventDispatcher
    ->dispatch(JwtAuthEvents::GENERATE, $event);
  $jwt = $event
    ->getToken();
  return $this->transcoder
    ->encode($jwt);
}