Laravel Socialite + Ionic (Sign up with Facebook or Google)

My website already has login with Fb or Google function and it’s working fine, now I want to connect it to my ionic app. I wrote the code, and in Ionic it’s connecting to Fb API successfully but not posting a request to my server (Laravel), there’s no change in the DB. Can anyone figure out what is the issue? Here’s my code:

Laravel - Api Social Controller:


 public function mobileProviderLogin($provider)
    {
        try{
            $userinfo = Socialite::driver($provider)->user();
        }catch (\Exception $e){
           return response()->json(array("status" => false,  "message" => "Login failed!"));        }

        Log::debug($userinfo->getId());
        $socialProvider = SocialProvider::where('provider_id',$userinfo->getId())->first();
        if(!$socialProvider){

           
                Log::debug('CONTINUE 1.1');
                $user = User::firstOrCreate(
                    ['name'=>$userinfo->getName(), 'display_name' => $userinfo->getName()] //Create With including email
                );
                
                Log::debug('CONTINUE 1.2');
                $user->socialProvider()->create([
                    'provider_id' =>$userinfo->getId(),
                    'provider' => $provider
                ]);
           
        }
        else
        {
            Log::debug('CONTINUE 2.1');
            $user=$socialProvider->user;
            Log::debug('CONTINUE 2.2');
        }
        
        if ($user != null)
        {
            Log::debug('CONTINUE 3.1');
            auth()->login($user);
        }
   
return response()->json(array("status" => true,  "message" => "Login success!"));  }

Ionic - service.ts:

  mobileProviderLogin(res: any) {

    return this.http.post(this.env.API_URL + 'auth/mobileProviderLogin', {res:res}
    )
  }

Ionic - Login.ts:

fbLogin() 
 {
  this.fb.login(['public_profile', 'email'])
    .then(res => {
      if (res.status === 'connected') {
        this.isLoggedIn = true;
        this.getUserDetail(res.authResponse.userID);
        this.authService.mobileProviderLogin(res);
        this.route.navigate(['/home']); 
      } else {
        this.isLoggedIn = false;
      }
    }),  (error: any) => {
      console.log(error);
         }
}

Can anyone help please? @IonicGeoff @Ionic_user23 @ionic-templates @ionictgraj @IonicDevScott @masterofevil @Masterdoc @Masteryuyu @masterpage @mastercrea1928 @masterpiece

@rafaelmoura @nb1990 @Joshmat @rloui @jamesharvey @crmontiel @Sujan12 @Arkantas can u guys help me please?

Well, you’ve got a fair bit going on there?

First of all, find out where the error is, it’s not clear, to me, whether it’s in your Laravel code, or Ionic code?

How is your website logging in? What/How/Where is posted from your website to log in successfully?

Are you using REST Client software, such as Insomnia, to test your web service and log in?