I ran into the same issue and I did not find any more documentation on this issue.
So, here is what I did that seems wonderful, you will tell me if you see something wrong.
In my applications, I will use clients to provide the password that I create on the fly for each client of my application. By client, I mean a browser, or a mobile application, or something else.
Each browser checks at startup if they have client_id and client_secret in localStorage (or cookies or something else). Then, if they do not, they will name the endpoint of your API, which will create a client for providing the password and return the information to the browser.
Then the browser will be able to log in using this new client information and their credentials.
Here is the controller that I use to create the password submission client:
<?php namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Http\Request; use Laravel\Passport\ClientRepository; class AuthController extends Controller { protected $hasher; protected $clients; public function __construct (Hasher $hasher, ClientRepository $clients) { $this->hasher = $hasher; $this->clients = $clients; } public function makeClient (Request $request) { $client = $this->clients->create(null,$request->header('User-Agent','Unknown Device'), '', false, true); return $client->makeVisible('secret'); } }
As you can see, as the name is for the client, I am trying to save the browser user-agent. Therefore, I can potentially display a page for my user with all his clients and give him the right to withdraw some clients, for example:
"Google Chrome, New York." You can also save the client IP address or anything there that will help you more accurately determine the type of client type ...
Hammerbot
source share