Identifier “jwt” is not defined

Hi everyone,
i m used Slim3 Framework Authorization with JWT

I am having an issue after running and getting a login token trying to access /api/

I get this error:

Slim Application Error

The application could not run because of the following error:

Details

Type: Slim\Exception\ContainerValueNotFoundException

Message: Identifier "jwt" is not defined.

File: /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/Container.php

Line: 120

Trace

#0 /Users/hanifeoglu/Sites/slim-framework3-jwt/src/routes.php(40): Slim\Container->get('jwt')

#1 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)

#2 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)

#3 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/Route.php(335): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)

#4 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))

#5 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/Route.php(313): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))

#6 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/App.php(495): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))

#7 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/tuupola/callable-handler/src/CallableHandler.php(34): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))

#8 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/tuupola/slim-jwt-auth/src/JwtAuthentication.php(150): Tuupola\Middleware\CallableHandler->handle(Object(Slim\Http\Request))

#9 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/tuupola/callable-handler/src/DoublePassTrait.php(30): Tuupola\Middleware\JwtAuthentication->process(Object(Slim\Http\Request), Object(Tuupola\Middleware\CallableHandler))

#10 [internal function]: Tuupola\Middleware\JwtAuthentication->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))

#11 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Tuupola\Middleware\JwtAuthentication), Array)

#12 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))

#13 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))

#14 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))

#15 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/App.php(388): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))

#16 /Users/hanifeoglu/Sites/slim-framework3-jwt/vendor/slim/slim/Slim/App.php(296): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))

#17 /Users/hanifeoglu/Sites/slim-framework3-jwt/public/index.php(30): Slim\App->run()

#18 {main}

I’m not super familiar with the Slim 3 framework, but it looks like the container is looking to find the JWT somewhere.

To figure out how that might be happening, we need to figure out first what you are trying to do with the framework.

Is this a PHP web app or a REST API?

If it is a REST API, then you would be passing the JWT as a Bearer token to the Authorization Header.

If it is a regular Web App, then you should be redirecting to /authorize with response_type=code and then you should be exchanging the code for tokens in a callback.

Slim 3 may be doing this for you, if so, can you post the configuration here? Please make sure you do not post your client_secret or even client_id. Just put fake data in. I just want to see how Slim3 configures its OIDC interactions. If it is doing this for you, then you will want to try to figure out whether you are getting a valid code or not. You can do this by watching the network calls in your developer console in chrome.