I have implemented authorization through facebook using laravel. When I am on the site, and I click on the authorization button via facebook, then there is a redirect to the page with the error "Sorry, something went wrong. We're working on getting this fixed as soon as we can". enter image description here Already spent almost all, and did not find a solution for this problem.
URL where the error is located https://www.facebook.com/v3.3/dialog/oauth?client_id=2040703196275670&redirect_uri=https%3A%2F%2Fgrowexspeak.space%2Ffacebook%2Fcallback&scope=email&response_type=code
I leave the authorization code through facebook made through on Laravel.
FacebookController.php
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Laravel\Socialite\Facades\Socialite;
class FaceBookController extends Controller
{
public function loginUsingFacebook()
{
$facebook_user = Socialite::driver('facebook')->stateless()->redirect();
return $facebook_user;
}
public function callbackFromFacebook()
{
try {
$user = Socialite::driver('facebook')->stateless()->user();
$saveUser = User::updateOrCreate([
'facebook_id' => $user->getId(),
],[
'name' => $user->getName(),
'email' => $user->getEmail(),
'password' => Hash::make($user->getName().'@'.$user->getId())
]);
Auth::loginUsingId($saveUser->id);
return redirect()->route('home');
} catch (\Throwable $th) {
throw $th;
}
}
}
config/services.php
facebook' => [
'client_id' => '####', //USE FROM FACEBOOK DEVELOPER ACCOUNT
'client_secret' => '####', //USE FROM FACEBOOK DEVELOPER ACCOUNT
'redirect' => 'https://growexspeak.space/facebook/callback'
],
Web.php
Route::prefix('facebook')->name('facebook.')->group( function(){
Route::get('auth', [FaceBookController::class, 'loginUsingFacebook'])->name('login');
Route::get('callback', [FaceBookController::class, 'callbackFromFacebook'])->name('callback');
});
App.php
'providers' => [
Laravel\Socialite\SocialiteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
])->toArray(),
auth.blade.php
<a href="{{ route('facebook.login') }}" class="btn btn-facebook btn-user btn-block">
<i class="fab fa-facebook-f fa-fw"></i>
Login with Facebook
</a>
Until I know the solution