© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
cakan

Filament login using API

I want to use filament for my project without database. Instead, it will use external API to fetch the data. I know that I can use Sushi library to work with data models.

What I don't know how to do is login user using external API. I've managed to make the login work with Sushi, but I can't use
Filament::auth()->attempt()
Filament::auth()->attempt()
.

I have extended authenticate method of Filament login page with this code:
$data = $this->form->getState();

$uri =config('service.api.url');
$res = Http::post($uri, $data)->json();

if (!isset($res['token_data']) && !isset($res['user'])) {
    $this->throwFailureValidationException();
}

$user = new User();
$user->fill($res['user']);
Filament::auth()->setUser($user);

if (!$user->canAccessPanel(Filament::getCurrentPanel())) {
    Filament::auth()->logout();
    $this->throwFailureValidationException();
}

session()->regenerate();

return app(LoginResponse::class);
$data = $this->form->getState();

$uri =config('service.api.url');
$res = Http::post($uri, $data)->json();

if (!isset($res['token_data']) && !isset($res['user'])) {
    $this->throwFailureValidationException();
}

$user = new User();
$user->fill($res['user']);
Filament::auth()->setUser($user);

if (!$user->canAccessPanel(Filament::getCurrentPanel())) {
    Filament::auth()->logout();
    $this->throwFailureValidationException();
}

session()->regenerate();

return app(LoginResponse::class);

This partially works but guards don't work any more. What is the correct way of doing this?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to login using Another API in filament panel
FilamentFFilament / ❓┊help
3y ago
filament login
FilamentFFilament / ❓┊help
2y ago
Admin panel login using API
FilamentFFilament / ❓┊help
3y ago
Login with API using Postman
FilamentFFilament / ❓┊help
3y ago