I have the client_id from oauth_clients and need to get the secret. Not possible to make a normal Model query or DB query, since the secret property is protected.
1条回答 默认 最新
doubu2730 2017-11-14 14:24关注You can access the
client_idandclient_secretif you know theoauth_clientsid:/** * 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); }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报