Reputation: 81
I have a Laravel application in which I'm using Passport for authentication. I have multiple questions about the Passport authentication:
oauth_access_tokens
) even if the user has a new token and can I avoid this huge storage?Thanks
Upvotes: 0
Views: 678
Reputation: 7618
Tokens can be removed by using one of the artisan commands that come with it:
php artisan passport:purge --expired
So you could call this artisan command using the scheduler, say once a day.
See https://laravel.com/docs/7.x/passport#purging-tokens for additional info.
As for your second question, well there are various ways to do that. One way is explained here https://laravel.com/docs/7.x/passport#consuming-your-api-with-javascript , which explains how you can add a middleware which attaches a laravel_token
cookie to each request. This cookie is then automatically sent from your JavaScript requests, and will authenticate the user.
Upvotes: 1