管理令牌laravel护照

时间:2019-12-18 11:06:21

标签: laravel-5 laravel-passport

我正在尝试管理acces令牌

当客户呼叫路由oauth / token时,他使用以下代码获取新令牌

  public function login(Request $request)
  {

    $this->validate($request, [
      'identifiant' => 'required',
      'motDePasse' => 'required'
    ]);

    Log::info('WS_API __ Authentification : ' . json_encode($request->all()));

    $params = [
      'grant_type' => 'password',
      'client_id' => $this->client->id,
      'client_secret' => $this->client->secret,
      'username' => request('identifiant'),
      'password' => request('motDePasse'),
      'scope' => '*'
    ];

    $request->request->add($params);

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

    $dispatch = Route::dispatch($proxy);

    if ($dispatch->getStatusCode() == '200') {

      Log::info('WS_API __ Authentification : ' . json_encode($request->all()) . ' with STATUS : ' . $dispatch->getStatusCode());

      $content = json_decode($dispatch->getContent());
      return response()->json([
        'token' => $content->access_token
      ]);
    }

    return Route::dispatch($proxy);
  }

我如何管理令牌?撤消现有令牌或将其删除

0 个答案:

没有答案