Laravel 5.5 socialite integration shows error formatRedirectUrl() must be of the type array, null given

Nithin John picture Nithin John · Nov 18, 2017 · Viewed 14k times · Source

I am using "laravel/socialite": "^3.0", to facebook login. But it shows an error

Type error: Argument 1 passed to Laravel\Socialite\SocialiteManager::formatRedirectUrl() must be of the type array, null given, called in /var/www/html/mas/vendor/laravel/socialite/src/SocialiteManager.php.

It happens when I am calling the below function in my login controller

public function socialLogin($social)
{
    return Socialite::driver($social)->redirect();
}

Answer

Jd Patel picture Jd Patel · Nov 18, 2017

Hi you are missing to give credentials of social media put that in config/services.php

'facebook' => [
        'client_id' => env('FACEBOOK_CLIENT_ID'),
        'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
        'redirect' => env('CALLBACK_URL_FACEBOOK'),
    ],
    'google' => [
        'client_id' => env('GOOGLE_CLIENT_ID'),
        'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        'redirect' => env('CALLBACK_URL_GOOGLE'),
    ],
    'twitter' => [
        'client_id' => env('TWITTER_CLIENT_ID'),
        'client_secret' => env('TWITTER_CLIENT_SECRET'),
        'redirect' => env('CALLBACK_URL_TWITTER'),
    ],
    'linkedin' => [
        'client_id' => env('LINKEDIN_CLIENT_ID'),
        'client_secret' => env('LINKEDIN_CLIENT_SECRET'),
        'redirect' => env('CALLBACK_URL_LINKEDIN'),
    ],
    'instagram' => [
        'client_id' => env('INSTAGRAM_CLIENT_ID'),
        'client_secret' => env('INSTAGRAM_CLIENT_SECRET'),
        'redirect' => env('CALLBACK_URL_INSTAGRAM'),
    ],