Support the ongoing development of Laravel.io →
Authentication Eloquent Packages

Hi,

I know , that exists way how to login users by theirs ids:

Auth::loginUsingId($user_id)

but how to do it in JWT Auth? I tried something like this:

JWTAuth::loginUsingId($user_id)

but it returns me error: Method loginUsingId does not exist!

So, how to login user by their user_id in jwt auth?

Last updated 2 years ago.
0

JWTAuth is token base login system whereas Auth is basic authentication system.

As JWTAuth require token, you can pass token in user object like:

$user = User::find($user_id);
JWTAuth::fromUser($user);

Get more idea for create token Hope this works!

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

matejMurin matejmurin Joined 28 Jul 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.