Thursday, 20 August 2020

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

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_page',
            '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?



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

No comments:

Post a Comment