$tg = new TokenGuard(
app()->make(ResourceServer::class),
Auth::createUserProvider(‘表命’), //這裡隨便寫就好了
app()->make(TokenRepository::class),
app()->make(ClientRepository::class),
app()->make(‘encrypter’)
);
// 利用反射機制 獲取getPsrRequestViaBearerToken
$workerClass_by_classinstance = new \ReflectionClass(TokenGuard::class);
$method = $workerClass_by_classinstance->getMethod(‘getPsrRequestViaBearerToken’);
$method->setAccessible(true);
$oauth_access_token_id = $method->invoke($tg,$request)->getAttributes()[‘oauth_access_token_id’];
//這樣就可以處理一些特殊驗證了
$oauth_access_tokens = DB::table(‘oauth_access_tokens’)->where(‘id’,$oauth_access_token_id)->first();
本作品採用《CC 協議》,轉載必須註明作者和本文連結