Passport: Call to a member function forceFill() on null when using with jenssegers/mongodb package

Created on 11 Aug 2017  ·  4Comments  ·  Source: laravel/passport

Hi,
I have problem with passport when setup in laravel 5.4 and jenssegers/mongodb package has installed.

I got error bellow when I run this code:
$user->createToken('Personal Token')->accessToken;

Error like this
screen shot 2017-08-11 at 7 11 07 pm

Anyone help me, please!

Most helpful comment

in TokenRepository
change
public function find($id)
{
return Token::find($id);

}

to
public function find($id)
{
return Token::where('id', $id)->first();
}

All 4 comments

in TokenRepository
change
public function find($id)
{
return Token::find($id);

}

to
public function find($id)
{
return Token::where('id', $id)->first();
}

@nolanle
How did you solve this problem?
I faced same issue.
It seems that it doesn't depend on MongoDB. I'm using MySQL.
https://github.com/laravel/passport/issues/713

in TokenRepository change
public function find($id)
{
return Token::find($id);
}
to
public function find($id)
{
return Token::where('id', $id)->first();
}

This is resoved my problem!
Did you try?

Still facing same issue, but on some attempts it work but fails mostly.

{
"message": "Call to a member function forceFill() on null",
"exception": "Symfony\Component\Debug\Exception\FatalThrowableError",
"file": "/var/app/current/vendor/laravel/passport/src/PersonalAccessTokenFactory.php",
"line": 75,
"trace": [
{
"file": "/var/app/current/vendor/laravel/framework/src/Illuminate/Support/helpers.php",
"line": 1041,
"function": "Laravel\Passport{closure}",
"class": "Laravel\Passport\PersonalAccessTokenFactory",
"type": "->"
},
{
"file": "/var/app/current/vendor/laravel/passport/src/PersonalAccessTokenFactory.php",
"line": 79,
"function": "tap"
},

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SwiTool picture SwiTool  ·  3Comments

s4uron picture s4uron  ·  3Comments

andcl picture andcl  ·  3Comments

seriousjelly picture seriousjelly  ·  3Comments

duccanh0022 picture duccanh0022  ·  3Comments