Ani
Ani

Reputation: 561

How to fix 'Facebook has detected MyApp isn't using a secure connection to transfer information.' error in Laravel

enter image description here

I am trying to connect my app to facebook login with Laravel and socialite package.But i don't know why facebook show me this error. I searched internet but i couldn't find anything .How can i fix this error ?

I thought that if i make my connection with https it will work but after making https again error appears.

My code in laravel:

web.php

Route::get('login/{provider}', 'SocialController@redirect');
Route::get('login/{provider}/callback','SocialController@Callback');

SocialController.php

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

    public function Callback($provider){

        $userSocial =   Socialite::driver($provider)->stateless()->user();
        $users       =   User::where(['email' => $userSocial->getEmail()])->first();
        if($users){
            Auth::login($users);
            return redirect('/');
        }else{$user = User::create([
                'username'          => $userSocial->getName(),
                'email'         => $userSocial->getEmail(),
                'provider_id'   => $userSocial->getId(),
                'provider'      => $provider,
            ]);
            return redirect()->route('home');
        }
    }

Upvotes: 35

Views: 38593

Answers (5)

Vasiliy  Shakhunov
Vasiliy Shakhunov

Reputation: 398

It looks like time expiration. I've just created another Facebook app and it works without that error.

Upvotes: 3

mon
mon

Reputation: 360

You can do "Create Test App" and replace your App ID and Secret using the test app.

enter image description here

Upvotes: 35

Karol Sobański
Karol Sobański

Reputation: 434

The simple answer is - Facebook will send sensitive data to provided redirect_uri, so it is ensuring this connection is private, by forcing you to use valid SSL.

As long as you do not setup a valid domain with proper certificate, Facebook won't let you use production API.

Upvotes: 4

K.M.S
K.M.S

Reputation: 111

You can use ngrok to make your localthost https. download and run ngrok.exe.

Then run command ngrok.exe http {port}. In most cases, it will be 8000.

Upvotes: 1

Prakash Khadka
Prakash Khadka

Reputation: 173

In case of angular : try to serve your app in secured socket layer true mode as Facebook is detecting insecure connection

Use the following command:

ng serve --ssl true

Upvotes: -6

Related Questions