如何从具有客户端凭据授权令牌的请求中获取客户端ID [重复]

This question already has an answer here:

I'm using Client Credentials Grant Token (https://laravel.com/docs/5.5/passport#client-credentials-grant-tokens) and I'm looking to get the client id from a request where a Bearer Authorization header is set. Is there a simple way to get this id?

</div>

I ended up setting client id as a request variable in my own CheckClientCredentials class. I copied vendor/laravel/passport/src/Http/Middleware/CheckClientController.php into app/Http/Middleware/CheckClientController.php and updated the handle method to

public function handle($request, Closure $next, ...$scopes)
{
    $psr = (new DiactorosFactory)->createRequest($request);

    try {
        $psr = $this->server->validateAuthenticatedRequest($psr);
    } catch (OAuthServerException $e) {
        throw new AuthenticationException;
    }

    $request["oauth_client_id"] = $psr->getAttribute('oauth_client_id');

    $this->validateScopes($psr, $scopes);

    return $next($request);
}

I then updated the references to CheckClientCredentials in app/Http/Kernel.php I can then grab the client id in my controllers using $request["oauth_client_id"].