Passport redirecting for authorization redirects to login route

Published 6 months ago by tuytoosh

Hi all, I want to use Passport for API authentication and I am going with laravel passport documentation, in requesting tokens, we need to redirect client to app for authorization, when I send get request for redirect, laravel redirects me to login route...



Well I need more context to help you further. Can you show some code?


@bobbybouwmann Thank you for answer, This is my route for redirecting for authorization and it returns me to login route :(

Route::get('/redirect', function () {
    $query = http_build_query([
        'client_id' => '1',
        'redirect_uri' => '',
        'response_type' => 'code',
        'scope' => '',

    return redirect(''.$query);

Well your code is correct, but the problem is with the redirect_uri. It should not redirect to your localhost, but rather to an external url.

Currently you're building the oauth server. When someone tries to get access you need to redirect back to their application. That is the redirect_uri. In the example in the documentation they use the domain to show you that this are two different applications.

The reason that you get redirected to the login screen is because /something_else probably needs some authentication, but the authentication is never handled there. So you can use the same url, but then you need to handle the token you get back from the redirect_uri. So you need to reuse the token you get back.


@bobbybouwmann I changed redirect_uri to but still I have same problem...

bobbybouwmann should be a website that connects to your application. That can be your own domain or a third party domain


@bobbybouwmann The problem is with oauth/authorize route... when I enter this route manually in address bar, it redirects me to login route again!

Please sign in or create an account to participate in this conversation.