robbamos / laravel-nuxt

A quick start template for a Nuxt.js + Vuetify frontend and Laravel 5.7 backend, including JWT auth.
7 stars 4 forks source link

Authorization grant (oauth) flow for social login with nuxt + laravel passport? #2

Open connecteev opened 5 years ago

connecteev commented 5 years ago

Hey @robbamos thanks for the repo.

I haven't gone through the motions of installing this yet (though I noticed you removed Passport)

Do you know how to do an Authorization grant (oauth) flow for social login (Google/Twitter authentication) with laravel passport (versus the password grant flow). Need to do this using Nuxt and Laravel...any pointers to sample code that does this would be great.

robbamos commented 5 years ago

Hey @connecteev,

You can wap out the Tymon JWT library for Laravel Passport pretty easily, you'll just need to update the Auth Controller to reflect that (as well as the user model, migrations etc).

For oauth, i'd suggest having a look at the Laravel Socialite library. You can integrate the built-in nuxt auth strategies for each of the providers, and then you'll need to modify your api's auth middleware to attempt to verify via socialite's stateless method.

Hopefully that helps,

I think I've got a test implementation of the social auth flow floating around somewhere, I'll post it up in a couple of days,

Cheers.

connecteev commented 5 years ago

Hey @robbamos thanks man, that would be great. I have indeed looked at the socialite docs, nuxt auth docs and some of the links you sent...I have socialite working with Plain Laravel (and even Socialite auth with Nuxt, just not Socialite + Laravel Passport with Nuxt as an OAuth flow). I need this to store the user's tokens for allow subsequent API access.

Is the test implementation you have of the social auth flow in Laravel Passport + Nuxt? That would save me some time.