Back

Dynamic callback url laravel socialite


leartgjoni posted 2 years ago

I tried to make my callback url dynamic because I'm configuring socialite in a multi auth system. I tried to use the socialiteproviders/manager as below:

public function redirect($provider)
{
    $clientId = "client_id";
    $clientSecret = "client_secret";
    $redirectUrl = "callback-url";
    $config = new \SocialiteProviders\Manager\Config($clientId,$clientSecret,$redirectUrl);
    return Socialite::with($provider)->setConfig($config)->redirect();

}

but it says: Call to undefined method Laravel\Socialite\Two\FacebookProvider::setConfig() when trying to login with facebook.

Please help me.

aaron94 replied 1 year ago

Hi, try this:

public function redirect($provider)
{
    $redirectUrl = "callback-url";
    return Socialite::with($provider)->redirectUrl($redirectUrl)->redirect();
}
AmbitionPHP replied 11 months ago

@aaron94 this works well for Facebook, but it seems as if you cannot set redirectUrl when using Twitter provider. Any ideas?

rahulsharma841990 replied 6 months ago

@AmbitionPHP try this way:

public function socialLogin($loginFrom){
  return Socialite::driver('facebook') >redirectUrl('http://your-domain.com?data=123')->redirect();
}

Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us