Im working with socialite and jwt auth here's my code
class SocialAuthFacebookController extends Controller
{
/**
* Create a redirect method to facebook api.
*
* @return void
*/
public function redirect()
{
$provider = 'facebook';
try {
$socialite = Socialite::driver($provider)->redirect();
} catch (InvalidStateException $e) {
$socialite = Socialite::driver($provider)->stateless()->redirect();
}
return $socialite;
}
/**
* Return a callback method from facebook api.
*
* @return callback URL from facebook
*/
public function callback(SocialFacebookAccountService $service, Request $request)
{
if($request->has('code')) {
$user = $service->createOrGetUser(Socialite::driver('facebook')->user());
$token = JWTAuth::fromUser($user);
return redirect("/#/dashboard")->with('token', $token);
} else {
return Socialite::driver($provider)->redirect();
}
}
}
I can get my $token and $user from my fb login callback but when I redirect it back to dashboard I still not able to login. Any idea?
because JWT is stateless and socialite is statefull. I'm guessing you're using a front framework like react or similar, you will need to have socialite be used by your front framework.