PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

Wave - Social Authentication - how to make it work?

Solved
droenfeldt

Nov 15th, 2024 02:03 PM

I spent almost 8 hours on this, but everything I tried doesn't seemt to work.

After enabling the Facebook network according to the official Wave instructions, I went ahead and created an app on the Facebook developers portal. After filling out all the necessary info and getting my app approved by Facebook and publishing it, the social authentication feature refuses to work. Here's what's happening:

After clicking the "Continue with Facebook" button, I'm getting redirected to a Facebook URL and the error message below is shown:

social-facebook-error.png

I made sure that both Client OAuth and Web OAuth Login toggles are on under Use Cases > Customize > Facebook Login > Settings > Client OAuth Settings. Also, I added all my app domains as Valid OAuth Redirect URIs. More specifically, I tried with all the URIs below, but alas it didn't work.

  • domain.tld/auth/register
  • domain.tld/auth/login
  • domain.tld/
  • domain.tld/dashboard
  • domain.tld/livewire/update
  • domain.tld/auth/facebook/redirect

What am I missing here? I'm literally at my wits end :(

droenfeldt

Nov 15th, 2024 02:38 PM

It looks like adding domain.tld/auth/facebook/callback as Valid OAuth Redirect URI made it work. Well, kind of.

That's because, regardless whether I'm trying to register (at domain.tld/auth/register), or log in (at domain.tld/auth/login), after clicking the "Continue with Facebook" button, and reaching the Continue as [facebooK_user] screen, and authorizing the authentication on the Facebook side, I'm getting returned to the login URL at domain.tld/auth/login with the #_=_ parameters appended to the end of the URL.

Also, the "An error occurred during authentication. Please try again." message is shown above the email input field.

bobbyiliev

Nov 16th, 2024 06:00 AM

Hey!

Happy to hear that you've got it working so far!

I just tested this and the following worked for me without any warnings:

Make sure that you also have the correct APP_URL setup in your .env file, it needs to exactly match your domain name including the https:// part.

Let me know how it goes!

- Bobby

Report
1
droenfeldt

Nov 16th, 2024 10:36 AM

Hey Bobby,

Thank you for your reply! My Facebook App setup is exactly like yours now (obviously with the exception of the domain name), and I made sure that the value of the APP_URL entry in my .env file matches exactly the domain name, including the https:// part. But, alas, I'm still getting the same "An error occurred during authentication. Please try again." message, and I'm getting returned to the login screen. That is, even if I tried to sign up, even though it happens exactly the same when I'm trying to sign in.

The most puzzling part to me is that, for some reason, the #_=_ string gets appended to the end of the login URI, like so:

https://domain.tld/auth/login#_=_

Any ideas?

Thanks a lot!

droenfeldt

Nov 19th, 2024 04:28 AM

The issue seems to occur during the social provider user creation, i.e. within the private method createSocialProviderUser() method of the SocialController.php Controller provided by the devdojo/auth package.

In a nutshell, when creating a new user with the help of the OAuth protocol, via the Facebook social provider, the method is successfully receiving the expected user data from Facebook (as arguments), but it fails when trying to persist the user to the database during the $user->socialProviders()->create() call.

I provided more details about this on GitHub.

bobbyiliev

Nov 20th, 2024 03:04 PM

Hey!

This is very helpful! Thank you for the additional information!

Do you by any chance also get any errors in the Laravel log at storage/logs/laravel.log?

In there you might have the exact error that is preventing the user from being created. If you could share that here it will be very helpful!

I will also try to reproduce this on my end in the meantime and keep the GitHub thread updated!

- Bobby

Report
1
droenfeldt

Nov 25th, 2024 06:29 AM

Hey Bobby!

I just cleared the log file and tried to authenticate with Facebook, (of course without success), but my log file is still empty.

Any other suggestions?

Thanks!

bobbyiliev

Dec 2nd, 2024 01:24 AM

Hey 👋

I've just updated the GitHub thread yesterday, I tried to look into this further and reproduce it locally on my end but it all seems to be working as expected.

A couple of things that come to my mind:

  • Regarding the empty log, can you confirm if you have APP_DEBUG=true set in your .env file? If not, can you set it and give it another try?
  • What type of database are you using, is it SQLite or MySQL for example?
  • Also in your browser web console, do you see any errors? You can try to: open the browser web console, then click on the register button and go through the flow and keep an eye on the console for any errors.
Report
1
droenfeldt

Dec 2nd, 2024 04:19 AM

Hey Bobby,

Thank you for your efforts! I've decided to set up a new Wave project from scratch and give the social login a go without modifying anyhitng else. I will let you know ASAP how it goes.

Many thanks!

bobbyiliev

Dec 2nd, 2024 06:00 AM

Hey!

This is a good idea! Let me know how it goes 🤞

droenfeldt

Dec 18th, 2024 04:13 PM

Best Answer

Hey Bobby,

I tried setting up a fresh Wave project with social auth but alas, it still won't work. I already spent way too much time on this, and therefore I'm gonna file it under the "Features I couldn't implement" category 😄 At least now I can't say I didn't try 😅

In any case, regardless of the result, I appreciate your guidance and efforts. I'll mark my reply here as accepted, while giving all credit where credit is due, to you, that is.