Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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();
}
like image 487
Nithin John Avatar asked Nov 18 '17 11:11

Nithin John


3 Answers

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'),
    ],
like image 166
Jaydeep Pedhadiya Avatar answered Nov 14 '22 15:11

Jaydeep Pedhadiya


You must clear the configuration cache file, how? if you use php artisan you will see the command config:clear. Run it:

php artisan config:clear

and now if you access to the $config variable inside the Laravel\Socialite\SocialiteManager::createFacebookDriver() you will get the configuration element stored in config/services.facebook (Facebook, for example) that before was not 'visible' for Socialite.

In short: run php artisan config:clear

like image 32
Siro_Diaz Avatar answered Nov 14 '22 13:11

Siro_Diaz


This happened to me just recently, fixed it after reading the following post here on StackOverflow:

Why do I have to run "composer dump-autoload" command to make migration work in laravel

The solution is basically to run the following commands:

php artisan clear-compiled composer dump-autoload php artisan optimize

like image 31
Mike Jimenez Avatar answered Nov 14 '22 14:11

Mike Jimenez