试图获得财产' id' createToken()之后护照上的非对象

时间:2018-04-18 17:37:29

标签: laravel restful-authentication laravel-passport

当我使用护照包时这样做,

$success['token'] =  $users->createToken('MyApp')->accessToken;

我将在此代码中处理错误:

  protected function createRequest($client, $userId, array $scopes)
{
    return (new ServerRequest)->withParsedBody([
        'grant_type' => 'personal_access',
        'client_id' => $client->id,
        'client_secret' => $client->secret,
        'user_id' => $userId,
        'scope' => implode(' ', $scopes),
    ]);
}

错误文字:

Trying to get property 'id' of non-object

为什么clinet variabale有null ??

1 个答案:

答案 0 :(得分:2)

我升级到^ 3.0时遇到了同样的问题。我运行了php artisan护照:install --force来重新生成密钥,并且有效。