API Authentication through Ajax
Hi,
I have a project that consists of an API written in Laravel that serves as a backend for a mobile application - and a Javascript client (hosted separately). The question I have is what is the recommended way to authenticate users via the API.
I understand that I could do this manually by passing the username and password through a request to the API and have the API pass back some kind of access token that can be used for the rest of that user's "session". - this is how I have done things in the past with 'non-laravel' applications I have written.
But I recently came across laravel/passport for API Authentication. It suggests that I use a web middleware to automatically create a 'laravel_token' can be used to authenticate ajax calls. This is ok if your javascript lives within laravel, but mine does not.
https://laravel.com/docs/5.4/passport#consuming-your-api-with-javascript
Can someone please recommend a way to do this - I would like to use as much of what is already available in the framework as possible to avoid writing from scratch.
Please or to participate in this conversation.