1

say I have a user that need to authenticate to my laravel 5.2 api ! the user do not have an api_token yet, so he is gonna give email and password to get back his api_token and store it (I may be wrong)! the question is how can I authenticate this users for the first time? is there a way in laravel 5.2 to do that ? something like Auth::guard('api')->attempt($array) ?

1 Answer 1

1

You can manually authanticate users by

Auth::login($user);

Your user should be a real user in users table in database.

So in your situation, you can get email address and username via form, insert it to database and login that user with the code above.

I hope it helps

Sign up to request clarification or add additional context in comments.

1 Comment

that code above will login the $user using the web guard not the api guard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.