Describe your issue here.
Windows
I've installed jwt-auth and implemented it into Customer class (instead of User).
use Tymon\JWTAuth\Contracts\JWTSubject;
class Customer extends Authenticatable implements JWTSubject
{
use Notifiable, SoftDeletes;
protected $guarded = [];
protected $hidden = ['password'];
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
}
When I run the following lines...
$credentials = $request->only('email', 'password');
if (!Auth::attempt($credentials)) {
//This "attempt" throws an error
}
I got an error message, saying that
"message": "Argument 2 passed to LcobucciJWTSignerHmac::createHash() must be an instance of LcobucciJWTSignerKey, null given, called in C:\projectsAppTrulyCrueltyFreeAPIvendorlcobuccijwtsrcSignerBaseSigner.php on line 34",
"exception": "SymfonyComponentDebugExceptionFatalThrowableError",
"file": "C:\projectsAppTrulyCrueltyFreeAPIvendorlcobuccijwtsrcSignerHmac.php",
"line": 21,
It seems that a third party library (Lcobucci\JWT) is causing this issue.
Strangely, this happens on Windows but not on Linux (Ubuntu).
Has anyone seen an error like this?
| Bug? | yes
| New Feature? | maybe no
| Framework | Laravel
| Framework version | 5.6
| Package version | "tymon/jwt-auth": "^1.0.0-rc.1"
| PHP version | 7.1
Tell us what should happen
Tell us what happens instead
run php artisan jwt:secret
Try. This worked for me.
$ php artisan cache:clear
$ php artisan route:clear
$ php artisan config:clear
Worked for me!
also make sure please you have 'secret' => env('JWT_SECRET'), and 'passphrase' => env('JWT_PASSPHRASE'), in your config/jwt.php
not working
@SantosDavid is right
run: php artisan jwt:secret
I worked on laravel 5.8
What worked for me is to set manually JWT_SECRET in Heroku. I generated a new key locally using php artisan jwt:secret and pasted it into Heroku config vars.
I was having a problem on Fortrabbit. The fix for me was to upload my .env file. It was in the .gitignore so it was not committed. At the bottom of the .env file is the JWT_SECRET.
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.
Most helpful comment
run php artisan jwt:secret