Passport redirecting for authorization redirects to login route
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 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 example.com 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.
Just in case other people stay in trouble on this.
I think its a misunderstanding on Passport authorization code flow.
It is normal that your Passport server redirects to login page.
In fact the third party application try to access /oauth/authorize route of the PAssport server.
The user have to authenticate on the Passport server to authorize or deny access to his data.
So laravel redirect the user to the login page so he can login.
After that he will be redirected to the authorize page.