Laravel 5.5 - laravel/socialite scopes and redirect

1.8k Views Asked by At

Can somebody explain to me what are scopes in laravel/socialite and how can I define multiple redirect from services.php

I need one for sign up with facebook, and another for login with facebook

config/services.php

'facebook' => [
        'client_id' => '***************',
        'client_secret' => '****************',
        'redirectForSignUp' => 'http://localhost:8000/register/facebook/callback',
        'redirectForLogin' => 'http://localhost:8000/login/facebook/callback',
 ],
2

There are 2 best solutions below

0
On

Open your .env file and set following value in it bottom

FACEBOOK_CLIENT_ID=xxxxxxxxx
FACEBOOK_CLIENT_SECRET=xxxxxxx
CALLBACK_URL=http://localhost:8000/auth/facebook/callback

Then after opwn config/services.php file and set following value

'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('CALLBACK_URL'),
],

Visit thiss link for full laravel/socialite configuration in laravel application

http://laravelcode.com/post/laravel54-login-with-facebook-in-laravel

0
On

The solution to this is:

public function redirectToProvider($accountType, $provider)
{
    return Socialite::driver($provider)
        ->with(['redirect_uri' => "http://localhost:8000/api/auth/{$accountType}/{$provider}/callback/"])
        ->redirect();
}

You could use this method to replace anything in the http request url (including scopes).

To override other things like scopes, simply:

->with([scopes => 'SCOPES HERE', redirect_url => ''])
->redirect();