When teh user click in the Login button with facebook where appears the error the url is like "https://www.facebook.com/v3.0/dialog/oauth?client_id=....&redirect_uri=http%3A%2F%app.test%2...&scope=email&response_type=code&state=....".
Jul 12, 2018
9
Level 3
Login with facebook is not working
I have the code below to login with facebook. But its not working it shows
“Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.".
Routes:
Route::get('auth/{provider}', [
'uses' => 'OauthController@redirectToProvider',
'as' => 'social.auth'
]);
Route::get('auth/{provider}/callback', [
'uses' => 'OauthController@handleProviderCallback',
]);
services.php:
'facebook' => [
'client_id' => '...',
'client_secret' => '...',
'redirect' => 'https://....ngrok.io/auth/facebook/callback'
]
OauthController:
class OauthController extends Controller
{
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}
public function handleProviderCallback($provider)
{
$userFace = Socialite::driver($provider)->user();
// $user->token;
$findUser = User::where('email', $userFace->email)->first();
if($findUser){
Auth::login($findUser);
}else{
$user = new User;
$user->name = $userFace->name;
$user->surname = "";
$user->email = $userFace->email;
$user->password = bcrypt($user->name);
$user->save();
Auth::login($user);
}
}
}
In Facebook I just edited the basic settings:
App Domains: https://...ngrok.io/
Site URL: https://...ngrok.io/auth/facebook/callback
Valid Oauth redirect URIs: https://...ngrok.io/auth/facebook/callback and "https://....ngrok.io/"
Use strict mode for Redirect URIS: yes
Please or to participate in this conversation.