79617293

Date: 2025-05-12 06:32:25
Score: 0.5
Natty:
Report link

When you run command

php artisan passport:client --password

You received information like: 
New client created successfully.  

  Client ID ........... <client_id>  
  Client Secret ... <secret>

And Laravel must save client secret to database with hash format.

And you can grant password with params like that:

url : <app_url>/oauth/token

params:

'grant_type' => 'password',
'client_id' => <client_id>,
'client_secret' => <,
'username' => <user_email>,
'password' => <user_password>,
'scope' => '*',

Example:


public function getTokenAndRefreshToken($email, $password)
    {
        $data = [
            'grant_type' => 'password',
            'client_id' => $clientId,
            'client_secret' => $secretId,
            'username' => $email,
            'password' => $password,
            'scope' => '*',
        ];
        $response = Http::asForm()->post(config('app.url') . '/oauth/token', $data);

        return json_decode((string)$response->getBody(), true);
    }

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: Hạ Huy