Search code examples
phplaravel-5.1jwtlumen

Get custom Claim in jwt-auth laravel


I need help to figure out a issues. I am using lumen(laravel 5.1) for create web services for mobile app. I am using JWT for authentication and it returns a token.

First issue is that if i use same token from another system/device then it validated and returns requested information. I want that token should be valid only for that device/system from user get token.

Second issue is that i have added some custom claims in JWT token. I want to get custom claim value from token. I have found similar question Get custom claims from a JWT using Owin but didn't get how i use it in php.

Please help me to get solution.


Solution

  • I got solution. Here is solution may be help someone else

    $payload = JWTAuth::parseToken()->getPayload();
    // then either of
    $payload->get('foo');
    $payload['foo'];