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

museumoftechno's avatar

SOLVED - Lumen API, users must log in to authenticate

*** UPDATE Sorry, I think I've worked out what to do: tymon/jwt-auth lets me attempt authentication by email/password, and issue a JWT token in one process. ***

I'd like to build a Vue SPA that consumes a Lumen REST API.

For API calls I'd like to authenticate by token; but users need to log in (username and password) to receive an API token, that's unique to their user account.

Lumen doesn't seem to make it easy for me to create a POST /login route to which I could submit login credentials: Laravel has its own Auth components, but Lumen's Auth components seem different by default, because it's designed to be sessionless.

So... can I somehow configure Lumen to allow different Auth functionality for different endpoints? I'd like to use a Laravel-style Auth::attempt($credentials) to validate user login, but then use Lumen-style API token authentication for subsequent API requests.

Or... do I find a way to hand-roll the login check code within Lumen?

Build a Laravel-based www.mydomain app purely for login, and Lumen for api.mydomain?

I hope that makes sense, I'd like the system to be as simple and unified as possible. Thanks.

0 likes
0 replies

Please or to participate in this conversation.