How to consume authenticated API in Laravel with Vuejs?

Asked

Viewed 853 times

2

I need to consume an API with Vuejs in Laravel 5.2, but it is authenticated, some hint for this process ?

  • Mikaell, welcome to Soft, see Help and take the Tour to understand how this community works and how to ask here. Put part of your code so we can understand and analyze your problem.

1 answer

4

It is not common for an API to use traditional Session authentication. What is usually used as protection is an Oauth server or JSON Web Token authentication.

If the authentication form cannot be modified, then your Vue components need to be served through Laravel routes along with Laravel’s views, all after the user authenticates in the application. From there any call to the API would not be barred by the authentication, which has already been made and the logged-in user is in Session.

In this case you would have a hybrid application.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.