Search code examples
laravelauthenticationoauthlaravel-passport

Can I use OAuth and Auth at the same time in Laravel?


I am doing a project in which I have implemented private chat in Laravel. But for the third party, we use OAuth but i have already used auth() in my project. Can I use both? OAuth is getting token, then communicate with Vue.js. So, I don't want to remove auth() functions in my project. Can you please guide me what to do?

Real time chat system in laravel project. I'm using separate Vue.js with Laravel.


Solution

  • Yes. You can use both OAuth and default Laravel Auth at the same time. In default, Laravel provides routes as web.php and api.php.

    web.php: This route uses default Laravel Auth functionality

    api.php: Routes defined here uses OAuth functionality

    Make sure you use default driver as web in config/auth.php

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],