laravel / passport

Laravel Passport provides OAuth2 server support to Laravel.
https://laravel.com/docs/passport
MIT License
3.25k stars 780 forks source link

Oauth/authorize doesn't work when I set the guard as api #1687

Closed zarpelon closed 9 months ago

zarpelon commented 9 months ago

Passport Version

11.8.4

Laravel Version

10.17.1

PHP Version

8.1

Database Driver & Version

Postgresl 15

Description

I defined the default guard as api in the passport.php settings.

When I try to use oauth/authorize, I receive that:

image

Steps To Reproduce

Install passport.

Set guard=api in passport.php

Try to use it:

Route::get("/redirect", function (Request $request) { $request->session()->put('state', $state = Str::random(40));

// Build the query parameter string to pass auth information to our request
$query = http_build_query([
    'client_id' => 'my_id',
    'redirect_uri' => 'my_url',
    'response_type' => 'code',
    'scope' => '',
    'state' => $state,
    'prompt' => 'consent',
]);

// Redirect the user to the OAuth authorization page
return redirect('http://localhost/api/v1/oauth/authorize?' . $query);

});

driesvints commented 9 months ago

You don't need to change this. Just keep it as web.