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

guiimarques18's avatar

How I make a Laravel Authentication in a Third Party API that use oAuth2?

I have an application in Laravel 5.7, I need authenticate the users in a other API (third party API), these API are code in REST with oAuth2. So, I want send a username and password to the URL-API and the callback is if the user are or not authorized to use the APP.

How I can make this?

0 likes
3 replies
tisuchi's avatar

Use Laravel Passport that provides by Laravel itself.

https://laravel.com/docs/5.8/passport

BTW, API authentication doesn't work the same way you are thinking. It's not a good idea to pass username and password to url for authentication.

2 likes
guiimarques18's avatar

Thanks, @tisuchi

But, how I can do this? Because I am building a project and this project need authentication in an API in other project. And other services will be used by API, so Laravel will work as a Client.

2 likes
2n2n's avatar

up! I'm also looking at laravel passport but I don't seem to grasp how to store the code that I got from the 3rd party api after approving the access

Please or to participate in this conversation.