user()->currentAccessToken(); if ($token instanceof ApiKey && $token->key_type === ApiKey::TYPE_APPLICATION) { // @phpstan-ignore instanceof.alwaysTrue throw new AccessDeniedHttpException('You are attempting to use an application API key on an endpoint that requires a client API key.'); } return $next($request); } }