Jwt-auth: Getting "does not contain the require claims" error, though included

Created on 20 Feb 2017  路  5Comments  路  Source: tymondesigns/jwt-auth

Hi,

I'm trying JWT for the first time, and this was the most recommended extension for Lumen. I'm having some difficulty, and hoping you can help me out. The docs are a bit sparse for Lumen, but I found some guides to get me going, and thought I'd try an example of a custom claim to learn more.

    var_dump(JWTFactory::make([
        'iss' => 'opweekends.local',
        'iat' => $now,
        'exp' => $now + 6000,
        'nbf' => $now,
        'sub' => 12,
        'jti' => md5('12'.$now)
    ]));

I first copied the examples straight in step 3 of the docs, but kept getting an error about not having all the required claims, so thought to try putting together my own array of the claim data. I know I can chain, but even as far as this, it still tells me I don't have the required claims. I logged out data at various steps, and it seems that 'sub' disappears somewhere on the chain, but I don't know where. Did I run into something funny, or do I not understand how this should work? I'm using beta 2.

Also, am I reading the docs wrong, or should I not be able to create a payload through the Factory that doesn't require the "required" keys?

Most helpful comment

I think that when you do the following the default/required claims are added :

$customClaims = [/* ... */];
$factory = JWTFactory::customClaims($customClaims); // set custom claims
$payload = $factory->make();

Another option might be to change the required claims in the config .. ?

All 5 comments

I also getting this error message while using "JWTFactory::make($customClaims)".
Where $customClaims are some variables (not including the default claims).

I got this error on Version 0.5.10
When i downgrade to 0.5.9 the problem is gone.

Exact Error message:
"_... Tymon\JWTAuth\Exceptions\TokenInvalidException: JWT payload does not contain the required claims in ..._"

Will this be fixed?

Having the exact same issue, had to revert back to 0.5.9

I guess I can look into using 0.5.9 with Lumen and manually utilizing the factory.

I think that when you do the following the default/required claims are added :

$customClaims = [/* ... */];
$factory = JWTFactory::customClaims($customClaims); // set custom claims
$payload = $factory->make();

Another option might be to change the required claims in the config .. ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CBR09 picture CBR09  路  3Comments

heroghost picture heroghost  路  3Comments

lbottoni picture lbottoni  路  3Comments

shah-newaz picture shah-newaz  路  3Comments

gandra picture gandra  路  3Comments