tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.29k stars 1.54k forks source link

Auth:api is not working #1901

Open NuclearGear opened 4 years ago

NuclearGear commented 4 years ago

Subject of the issue

I created a new laravel project and do the requirement steps that listed in the "quick start" of documentation. But I use PostMan or CUrl post a request to any endpoint in AuthController such as localhost:8000/api/auth/logout or localhost:8000/api/auth/me then got a result of login page and redirected to http://localhost:8000/login. But localhost:8000/api/auth/login is working.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 6.4
Package version 1.0.0
PHP version 7.3.2

Steps to reproduce

  1. Create new laravel project
  2. Do the requirement steps that listed in the "quick start" of documentation

Expected behaviour

Return current result

Actual behaviour

Return the login page

caleboki commented 4 years ago

Check the headers of your request in Postman. Specifically set the 'Accept' key to the value 'application/json'

NuclearGear commented 4 years ago

Hi @caleboki , thanks for your reply, I set the Accept Field to "application/json" in the Request then I get a json result, but the endpoint always result "message": "Unauthenticated.".

caleboki commented 4 years ago

It returns "message": "Unauthenticated." because you are not logged in. What result do you expect from it? to log in, send a POST request to the login endpoint passing in your login credentials

NuclearGear commented 4 years ago

It returns "message": "Unauthenticated." because you are not logged in. What result do you expect from it? to log in, send a POST request to the login endpoint passing in your login credentials

I get the details of result that "user not found" when I replace "Auth:api" to "jwt.auth" in controller,

ahmadsyamim commented 4 years ago

similar situation right now

DartedMonki commented 4 years ago

Very same problem with me, can't figure this out until now. Can someone help? Thanks

innoflash commented 4 years ago

Instead of auth:api use auth middleware.

I dont know whats happening though

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.