Jwt-auth: Auth::attempt throws an error "Lcobucci\JWT\Signer\Hmac::createHash()", even though I don't use jwt-auth anymore

Created on 30 Jul 2018  路  9Comments  路  Source: tymondesigns/jwt-auth

Subject of the issue

Describe your issue here.

Your environment

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

Steps to reproduce

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

stale

Most helpful comment

run php artisan jwt:secret

All 9 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johncloud200 picture johncloud200  路  3Comments

harveyslash picture harveyslash  路  3Comments

mihailo-misic picture mihailo-misic  路  3Comments

gandra picture gandra  路  3Comments

lbottoni picture lbottoni  路  3Comments