DEV Community

Discussion on: Build a JWT Authenticated API with Lumen(v5.8)

Collapse
 
dhavaldignizant profile image
dhaval-dignizant

getting this error after install jwt

php artisan jwt:secret

There are no commands defined in the "jwt" namespace.

Collapse
 
ndiecodes profile image
Ndifreke Friday

Please check to make sure tymon/jwt-auth installed successfully

Also type php artisan to see available commands.

Keep me posted on your progress.

Collapse
 
ndiecodes profile image
Ndifreke Friday

Side note: the command jwt:secret updates your .env file with something like JWT_SECRET=secretkeystring.

"It is the key that will be used to sign your tokens. How that happens exactly will depend on the algorithm that you choose to use."

Thread Thread
 
dhavaldignizant profile image
dhaval-dignizant

now it's working. Thank you.

Thread Thread
 
ndiecodes profile image
Ndifreke Friday

You are welcome

Thread Thread
 
dhavaldignizant profile image
dhaval-dignizant

Hi Ndifreke,
can you explain how to publish jwt library also need to token expire time and refresh token. thank you in advance.

Thread Thread
 
ndiecodes profile image
Ndifreke Friday

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

The above command publishes the JWTAuth Package. Here's this thing, the vendor:publish command is not available in lumen.
You can try using third party packages to pull this in ( github.com/laravelista/lumen-vendo... )

For managing expiration time and refreshing tokens, this link should help out; jwt-auth.readthedocs.io/en/develop...

Thread Thread
 
dhavaldignizant profile image
dhaval-dignizant

Hi Ndifreke,
Thanks for reply. one more thing I need if you help me. you have any example for lumen with vue also include in jwt token use.

Collapse
 
b6t3m6n profile image
B6T3M6N

Had the same issue.

following the docs here jwt-auth.readthedocs.io/en/develop...
especially the chapter Bootstrap file changes fixed the issue

Add the following snippet to the bootstrap/app.php file under the providers section as follows:

// Uncomment this line
$app->register(App\Providers\AuthServiceProvider::class);

// Add this line
$app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
Enter fullscreen mode Exit fullscreen mode