I have two codebases
1) Vue powered front-end application: example.com
2) Laravel Api: api.example.com
I'd like to implement basic register/login flow with Laravel Passport, but in a way that the token is "refreshed" on every API request. Otherwise, UX is very poor since the user can be logged out even if s/he uses the app actively.
I've read a bunch of articles and finally in here https://alexbilbie.com/guide-to-oauth-2-grants/ - I'm convinced that I need to use Implicit grant tokens.
But in my understanding, this code:
$query = http_build_query([
'client_id' => 'client-id',
'redirect_uri' => 'http://example.com/callback',
'response_type' => 'token',
'scope' => '',
]);
return redirect('http://your-app.com/oauth/authorize?'.$query);
redirect the user to the server-side login page, but I'll handle the login/register on the client-side and simply provide the credentials to the server.
So, how my server-side controller should look like, if I'm going to provide the necessary credentials (email/password) from client-side and ideally return the access_token?
Simply put: I want the authentication system to work very similarly than the basic web-based authentication on Laravel, but using tokens.
Btw, the reason why I use a passport in the first place is that the project will support a bunch of different authentication flows, e.g, SMS, etc.