2

I am using laravel 5.1

I want to make login using REST api. I have searched about Sentry. But there is no documentation for Laravel 5. I don't know it will work with laravel 5. I just want to know what is the best way to login my laravel application using REST?

Praveen Srinivasan
  • 1,562
  • 4
  • 25
  • 52
  • Sentry has a PHP package and docs, so you can write your own: https://docs.getsentry.com/hosted/clients/php/ or you can take a look at bugsnag, which provides a laravel package: https://bugsnag.com/docs/notifiers/laravel – craig_h Oct 15 '15 at 11:30
  • @craig_h pretty sure he's talking about https://cartalyst.com/manual/sentry/2.1 – andrewtweber Oct 15 '15 at 16:38
  • @andrewtweber oops, that makes more sense, I was blinded by the fact I was working with Sentry this morning. – craig_h Oct 15 '15 at 16:43

1 Answers1

1

Laravel for Rest API development Good Choice

Even I am using it for Rest API development

For Login I am using a session field from database which acts as token for validating user accessing the API so, if the request has the session token and it matches to the token from database then its a valid request this approach is taken by me for validating request to my API, And every login I am resetting the token

How to create the token

Token should be able to identify the user i.e. which user is sending the token for that I am creating token by hashing userID + salt(Random and very long string).

How it works

User who is able to access the API sends login credentials, if the credentials are valid I am creating token for the user and storing the token in database with the user whose credentials are provided and sending the token value to the user as response and next time I am validating each request with the Access token

Recommendation

Instead of Laravel you can consider using Lumen(A micro-framework by Laravel) also for developing rest API.

For detailed information about rest and rest authentication

How to do authentication with a REST API right? (Browser + Native clients)

What exactly is RESTful programming?

What is REST? Slightly confused

RESTful Authentication

Community
  • 1
  • 1
Akshay Khale
  • 8,151
  • 8
  • 50
  • 58