Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

junny_solano's avatar

Laravel 10 Passport Route

Hello, I have created a new laravel project and I have followed the steps to install and configure laravel passport, but when you create the login method to generate a token based on the documentation, it gives me a time out error.

https:// laravel. com/docs/10.x/passport#requesting-password-grant-tokens

I have tried with different routes, but it doesn't work, testing with:

  • http:// localhost/oauth/token
  • /oauth/token
public function login()
    {
        $response = Http::asForm()->post('/oauth/token', [
            'grant_type' => 'password',
            'client_id' => 'client-id',
            'client_secret' => 'client-secret',
            'username' => 'user1',
            'password' => 'passport1',
            'scope' => '',
        ]);

        return $response->json();
    }

Errors

Illuminate\Http\Client\ConnectionException: cURL error 28: Resolving timed out after 10000 milliseconds (see https:// curl.haxx.se/libcurl/c/libcurl-errors.html) for oauth/token in file /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 855

Illuminate\Http\Client\ConnectionException: cURL error 28: Operation timed out after 30002 milliseconds with 0 bytes received (see https:// curl.haxx.se/libcurl/c/libcurl-errors.html) for http:// localhost/oauth/token in file /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 855

The only way I've gotten it to work is to start an artisan server and use a different port than the api endpoint uses.

Could someone explain to me why this happens and how I can solve it?

0 likes
0 replies

Please or to participate in this conversation.