Laravel Passport - 通过客户端 ID 获取客户端密码

Laravel Passport - Get Client Secret by client id

我有来自 oauth_clients 的 client_id 并且需要获取 秘密 。 无法进行正常的模型查询或数据库查询,因为 secret 属性 受到保护。

如果您知道 oauth_clients ID,您可以访问 client_idclient_secret

/**
     * DefaultController constructor.
     */
    public function __construct()
    {
        $this->client = DB::table('oauth_clients')->where('id', 2)->first();
    }

    /**
     * @param Request $request
     * @return mixed
     */
    protected function authenticate(Request $request)
    {
        $request->request->add([
            'username' => $request->username,
            'password' => $request->password,
            'grant_type' => 'password',
            'client_id' => $this->client->id,
            'client_secret' => $this->client->secret,
            'scope' => '*'
        ]);

        $proxy = Request::create(
            'oauth/token',
            'POST'
        );

        return Route::dispatch($proxy);
    }