• Resolved Nomi

    (@naumanahmed19)


    Hi,

    Thanks for this plugin. I want to add extra information to jwt.

    I enabled and added hook but it’s not working.

    if(function_exists('simple_jwt_login_jwt_payload_auth')){
    
    	add_action( 'simple_jwt_login_jwt_payload_auth', function($payload, $request){
    
    		$payload['name'] = 'joe doe'; 
    		return $payload;
    
    	   }, 10, 2);
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author nicu_m

    (@nicu_m)

    Hello @naumanahmed19,

    Just remove the if(function_exists... and it should work.

    Your code should be like this:

    
    
    	add_action( 'simple_jwt_login_jwt_payload_auth', function($payload, $request){
    
    		$payload['name'] = 'joe doe'; 
    		return $payload;
    
    	   }, 10, 2);
    

    Best regards,
    Nicu.

    Thread Starter Nomi

    (@naumanahmed19)

    oh thanks, just a stupid mistake

    angelzeke

    (@angelzeke)

    HI, Nice and good plugin, have a problem for add extra data on payload
    – i have activate the hook
    – add in functions.php :

    add_action( ‘simple_jwt_login_jwt_payload_auth’, function($payload, $request){

    $payload[‘name’] = ‘joe doe’;
    return $payload;

    }, 10, 2);

    And when i call
    https://xxxxx.com/?rest_route=/simple-jwt-login/v1/auth&email=xxxxr&password=xxxx

    it’s always return

    {
    “success”: true,
    “data”: {
    “jwt”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDU4NjYyNjgsImV4cCI6MTYwNTg2OTg2OCwiZW1haWwiOiJSb21haW5AdmlsbGF1bWUuZnIiLCJuYW1lIjoiam9lIGRvZSJ9.oslp8UA_T74RrqaFeEKJc6RsZtlG9XzZHnEX8n_1jqY”
    }
    }

    I have my token and succes ?? but not extra data ??

    Hi,
    just quick help for @angelzeke. It is not an action but a filter

    Plugin Author nicu_m

    (@nicu_m)

    Hello,

    I’ve just decoded your JWT with https://jwt.io and the payload looks like this:

    
    {
      "iat": 1605866268,
      "exp": 1605869868,
      "email": "....",
      "name": "joe doe"
    }
    

    Just copy your JWT on this website, and you can view the payload.

    Another option is, to base64 decode the second segment of the JWT ( segments are separated by dots. Example: header.payload.signature )

    Let me know if you have other questions.

    Best regards,
    Nicu.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Extra data in jwt’ is closed to new replies.