You are here

public function JwtAuthIssuerController::tokenResponse in JSON Web Token Authentication (JWT) 8

Same name and namespace in other branches
  1. 8.0 modules/jwt_auth_issuer/src/Controller/JwtAuthIssuerController.php \Drupal\jwt_auth_issuer\Controller\JwtAuthIssuerController::tokenResponse()

Generate.

Return value

string Return Hello string.

1 string reference to 'JwtAuthIssuerController::tokenResponse'
jwt_auth_issuer.routing.yml in modules/jwt_auth_issuer/jwt_auth_issuer.routing.yml
modules/jwt_auth_issuer/jwt_auth_issuer.routing.yml

File

modules/jwt_auth_issuer/src/Controller/JwtAuthIssuerController.php, line 48

Class

JwtAuthIssuerController
Class JwtAuthIssuerController.

Namespace

Drupal\jwt_auth_issuer\Controller

Code

public function tokenResponse() {
  $response = new \stdClass();
  $token = $this->auth
    ->generateToken();
  if ($token === FALSE) {
    $response->error = "Error. Please set a key in the JWT admin page.";
    return new JsonResponse($response, 500);
  }
  $response->token = $token;
  return new JsonResponse($response);
}