79416969

Date: 2025-02-06 06:42:07
Score: 0.5
Natty:
Report link

Are you running this project through xampp? If not, is it through docker or any containers?

If you are running the laravel project through docker container, the port is usually going to be different from host machine and the containers.

However, if you are indeed running through xampp and using laravel's , then you might need to run 2 artisan server command.

Example)

1st terminal: Run php artisan serve --port=8070

2nd terminal: Run php artisan serve --port=8071

And then in your code, change the following:

$response = Http::post('http://localhost:8071/oauth/token', [
    'grant_type' => 'password',
    'client_id' => env('PASSPORT_PASSWORD_CLIENT_ID'),
    'client_secret' => env('PASSPORT_PASSWORD_SECRET'),
    'username' => $userData['email'],
    'password' => $userData['password'],
    'scope' => '',
]);

You should see something like this in your terminal output.

2 php artisan serve commands

Example response:

{
   "success":true,
   "statusCode":201,
   "message":"User has been registered successfully.",
   "data":{
      "name":"Test",
      "email":"[email protected]",
      "updated_at":"2025-02-06T06:29:53.000000Z",
      "created_at":"2025-02-06T06:29:53.000000Z",
      "id":4,
      "token":{
         "token_type":"Bearer",
         "expires_in":1296000,
         "access_token":"some token",
         "refresh_token":"some refresh token"
      }
   }
}

Hope this answers your question.

Thanks.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Tatachiblob