Authentication issue with Gmail using the Socialite package in Laravel 6 and Angular?

20 Views Asked by At

I am implementing authentication using Laravel and Angular with JWT. There is a login button that works well, and I have set up an Angular routing systemthat redirects to thelogin pageif the user is not authenticated. Here is therouting system`:

app-routing.module.ts

const routes: Routes = [

  {path:"", component:LandingPageComponent            }, 
  { path:"annonces",  children:[ 
    { path:"", component:IndexAnnonceComponent              },
    { path:"show/:slug", component:ShowAnnonceComponent  },
    { path:"add", component:AddAnnonceComponent          },
    { path:"edit/:slug", component:EditAnnonceComponent  }, 
    { path:"profil", component:ShowUserComponent  }, 
    { path:"chat", component:ChatComponent  }, 
    { path:"cart", component:CartComponent  }, 
    ], canActivate:[AuthGuard]
  },

  { path:"tinghirs",  children:[
    { path:"", component:IndexTinghirComponent                  },
    { path:"show/:slug", component:ShowTinghirComponent    },
    { path:"add", component:AddTinghirComponent             },
    { path:"edit/:slug", component:EditTinghirComponent     }, 
    ]
  },

  { path:"login",component:LoginComponent,canActivate:[AfterAuthGuard] },
  { path:"register",component:RegisterComponent                        },
  { path: "**", component:PageNotFoundComponent                        } 
];

I have added a "Sign in with Google" button, and I have configured Laravel and Angular, and it works fine socialite package. However, my problem is that when I click on the "Sign in with Google" button, it opens the Gmail site, I choose the Gmail account I want to authenticate with, but then it redirects to the login page. How can I resolve this issue?

0

There are 0 best solutions below