Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jwhm's avatar
Level 1

Laravel, Guzzle External API User Authentication.

Hi, I have access to a user API, which has a postable function validate($username, $password) which returns a Boolean, I don't have any direct access to any of that API(database etc), it's solely API based. What would be the best method of using Laravel's built in Auth, to authorise a login through that API?

This is all accomplished through Guzzle, I cannot use a locally stored database as syncing over 500 accounts an hour isn't feasible.

if($api->validate($request->input('username', password')) // Create Auth'd Session.

I want to be able to use Laravel's built in Auth system so I can access Auth::user(), etc.

0 likes
2 replies
martinbean's avatar

@jwhm If the API just returns a boolean, then how exactly are you expecting to authenticate a user in your application?

If you call Auth::id() after checking credentials, what is that method supposed to return if you don’t get anything from the API except true or false…?

1 like
jwhm's avatar
Level 1

Sorry, my bad. It returns an array, containing their email, and client_id, as well as a success Boolean.

Please or to participate in this conversation.