mercredi 18 décembre 2019

manage token laravel passport

i'm trying to manage acces tokens

when client call route oauth/token , he get new token using the code below

  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);
  }

how i can manage tokens ? by revoking existing token or deleting them



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire