Hello, We are developing a vue+Laravel application that will use another third-party REST API. Currently, we make API request from Vue to Laravel backend and Laravel make necessary API call to that third-party API.
Third-party API also needs an access token. Where we should keep this access token? In Laravel sessions? What is the best practice for these kinds of scenarios?
I assume it is a token that will be returned from the endpoint and will expire? And that it is unique for the frontend user? If so, I would most likely use session. If you need to keep track of them, you can also use the database.
@Sinnbeck Yes the token we got from when authenticating that third-party API. So it will unique for the frontend user. OK, I am going to use the Laravel session then.
currently, we keep this token in Vue local storage and send every request in headers. Which I think is a bad procedure.
@Sinnbeck It is ok to use sessions with API. I mean not that third-party one. Our own app has an API.
Example:
Get all users
/api/v1/user ( this is our own API )
within this API call, we call that third-party one. so we will get the access token from the session.
So we are going to use sessions with an API. Is it OK?
@thushara Ah if its for an actual API (not just an internal api for vue) I would store it in the database, so you dont need to enable sessions for your own api. If it is stateful already, you can just use sessions.