Slim 3 with Json web Token

Hi Everybody,
im new to Slim, i need implement jwt with slim, i use this
in the backend is fine, i try with this code only for example :

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';

$app = new \Slim\App;
$app->add(new \Slim\Middleware\JwtAuthentication([

$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;

the problem is when i call the api,i dont know how pass the jwt to the api, i try with autorization,
with header: “secret” “supersecretkeyyoushouldnotcommittogithub” but all return 401 not Unauthorized

What header have sent? According to the documentation, the expected header looks like:

Authentication: BEARER supersecretkeyyoushouldnotcommittogithub

yes i Try with uthentication: BEARER supersecretkeyyoushouldnotcommittogithub but dont work.

It seems you first need to make a call to fetch a token, then you can pass this token in the authentication header. There is an example Slim implementation that uses the slim-jwt-auth middleware at

@robertfernan Could you solve it?

yes thanks for your help

1 Like

@robertfernan :wink: Any example available? Have you configure some extra?

I do not really remember but try this