The issue I encounter is that when I try click the login via Facebook button, a popup is shown, it authenticates, a 302 request is sent to my server and then the request sent throws an error:
Failed to load https://www.facebook.com/v2.10/dialog/oauth?client_id=1869475260039930&redirect_uri=https%3A%2F%2Fordering.dev%2Fapi%2Flogin%2Ffacebook%2Fcallback&scope=email&response_type=code&display=popup: Response for preflight is invalid (redirect)
Route::post('login/{provider}', 'SocialAuthController@redirectToProvider');
Route::get('login/{provider}/callback', 'SocialAuthController@handleProviderCallback')->name('api-callback');
My Controller:
public function redirectToProvider($provider)
{
// will get called
return Socialite::driver($provider)->stateless()->asPopup()->redirect();
}
public function handleProviderCallback($provider)
{
// this endpoint is never called
return response()->json('test');
// more logic
}
Frontend code:
socialLogin(provider) {
console.log('social login');
let this_ = this;
// vue-authenticate
this.$auth.authenticate(provider).then(function () {
// success - never called
}).catch(function (err) {
// error is always thrown
console.log('error is', err);
});
}
How can I make sure that I my handleProviderCallback($provider)
function is called and passes through the correct info?