1

I have followed the tutorial below but when I get the current user it always returns false. I am able to sign in and get my token in postman. I then create the url and hit send. However the following function always returns false.

$currentUser = JWTAuth::parseToken()->authenticate();
dd(currentUser)

https://www.sitepoint.com/how-to-build-an-api-only-jwt-powered-laravel-app/

Update When I run the below code I get the token value.

$token = JWTAuth::getToken();
JWTAuth::setToken($token);

The code fails at the following point

if (! $user = JWTAuth::parseToken()->authenticate()) {
    return response()->json(['user_not_found'], 404);
}
Matt
  • 383
  • 1
  • 5
  • 20
  • you passed generated token with your request? https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2016/02/1455663699postman_other_test.png – Renish Khunt Jan 27 '17 at 05:12
  • that is correct like http://localhost:8080/test?token=123456. Using the token I was provided at login. – Matt Jan 27 '17 at 05:14
  • I did use an account that I signed up with via a form as apposed to the api. But still got the token when I logged in. – Matt Jan 27 '17 at 05:16
  • Yes, please see https://cask.scotch.io/2015/06/angular-laravel-auth-5-1.png – Renish Khunt Jan 27 '17 at 05:17
  • please read document. https://github.com/tymondesigns/jwt-auth/wiki/Authentication – Renish Khunt Jan 27 '17 at 05:22

1 Answers1

0

Below is the answer that solved my problem. I was using user_id as opposed to id. I changed this in the jwt config file.

Tymon JWT user_not_found - Laravel 5.1

More on this below

https://github.com/tymondesigns/jwt-auth/issues/155

Community
  • 1
  • 1
Matt
  • 383
  • 1
  • 5
  • 20