How to resolve unauthenticated issue in Postman GET Request

please provide some more details of your code and a screen shot of your postman request. it would be more helpful to give an answer.

Commented Apr 7, 2021 at 18:10

laravel gives token when you try to authenticate. It's done using post and the data is sent in raw (json/text) format.

Commented Apr 7, 2021 at 18:11 you could better have a look at this. positronx.io/… Commented Apr 7, 2021 at 18:12

3 Answers 3

This person walks you through the process nicely and should get you setup. https://coding-lesson.com/api-authentication-with-laravel-passport/

Basically you need to:

  1. Get to your login api, probably something like: localhost:8888/myapp/server/api/v1/login
  2. Create a POST request to the login API, select the Body tab and define key values for you Email and Password
  3. Then run the request and copy the AccessToken value from the results
  4. Now with your API above, select the Authorization tab, choose Bearer Token as the Type and paste in your AccessToken value for the Token field
  5. You should also go to your Headers table and define Accept and Content-Type keys, both with values of: application/json

Of course you'll want to then change all this to use variables after you get it right, so you don't have to keep repeating this with all your new API calls.

answered Apr 8, 2021 at 16:49 Rob.Kachmar Rob.Kachmar 2,178 1 1 gold badge 19 19 silver badges 23 23 bronze badges

To fetch data behind protected routes you need to provide a token that will verify that the user who made the call is authenticated.

Then you have to provide the token in Authorization section of postman.

answered Apr 7, 2021 at 18:15 11 2 2 bronze badges

I assume you know the difference between Post and Get . Laravel works a little different then regular PHP , let me tell you how.

Json Format

  1. In order to access the protected routes you'll have to first access the token from login route. By sending the required data in .
  2. Once that's done it'll return the token which can be used to access the protected routes under admin or auth middleware.

In your case you're accessing localhost:8888/myapp/server/api/v1/admin/role which is a protected route under admin middleware. You'll have to first access token and then send token with the get request to fetch the required data.