Hi Majeed, is there a reason why you would want to set the access token in the backend. My understanding is that the bearer token is used to check if a request is authenticated before allowing access to a protected route. If it is preset in the backend, it defeats the purpose of trying to authenticate the request.(unless I’m wrong)
Secondly, you are trying to access a bearer token from the $request object, when the token is not being passed in the first place.
I want this because when I send a request from browser to an API endpoints. where Postman isn't present. that situation how can i handle this Bearer Token. Please you have any solutions that's kind of situation suggest me. I'm new working with API. Thank You @Nee
@majeed You pass the Bearer token when issuing the request. You might want to have a look at Passport if you’re trying to use your own API in an application.
If you’re trying to automatically add a Bearer token via middleware, then there’s no point having authentication in your API at all.