In a custom module, I need to get the jwt token (access_token) related to the current user. Following this issue I've tried to get it, but without success, because get_jwt_key() and jwt_token_params() are not defined and I can't find where they are defined:
use \Firebase\JWT\JWT;
...
public function getAccessToken() {
$uid = \Drupal::currentUser()->id();
// Add JWT access_token
$key = get_jwt_key(); //key for generate jwt token
$token = jwt_token_params($uid); // parameters to be added in token.
$access_token = JWT::encode($token, $key);
return $access_token;
}
I've tried only with:
$access_token = $this->jwtAuth->generateToken();
But I haven't found how to initialize $jwtAuth service to generate the token. Any suggestion?