Laravel socialite login through facebook results in Sorry, something went wrong

Viewed 1129

I have a laravel project that uses facebook login. But after a few days of testing, when I go to the route, it says Sorry, something went wrong.. I did not touch or modified my code and as well as in the app in my facebook developers account. Can someone tell me what happened?

Here is my controller

    public function redirectToProvider(){
        $facebookScope = [
            'pages_manage_posts',
            'pages_read_engagement',
            'instagram_basic',
            'pages_show_list',
            'manage_pages',
            'publish_to_groups',
            'groups_access_member_info',
        ];
        return Socialite::driver('facebook')->scopes($facebookScope)->redirect();
    }

    public function facebook(){
        try {
            $user = Socialite::driver('facebook')->stateless()->user();
            // dd($user);
            // $this->getPages($user);
            $this->getGroups($user);
            } catch (\Exception $e) {
                return response()->json($e);
        }
    }

Routes

Route::get('/fb','FacebookController@redirectToProvider');
Route::get('/facebookAuth','FacebookController@facebook');

My facebook app oauth setting enter image description here

What the result look like

enter image description here

Laravel version: 6.2

Socialite verion: ^4.4

UPDATE: If i remove all the scopes, I can successfully login and get the credentials and the token. But why the scopes is not working?

3 Answers

This error do not specify what has gone wrong so its hard to tackle but you can check the logs for detail error report it will surely help you. The logs are located in storage directory. If you want laravel to display complete error for you rather than the cryptic 'Whoops' message, make sure in your .env APP_ENV=local is in there and your APP_DEBUG=true or you can tweak it in your config/app.php like

'env' => env('APP_ENV', 'local'),
'debug' => env('APP_DEBUG', true),

'debug' => env('APP_DEBUG', true),

and run php artisan config:cache command

actually you are on production server and that's why the error is not showing on there. Try to change the environment variable APP_DEBUG=true in .env file and check the exact error. it maybe due to Socialite package which you are using.

Related