سلام
این سوال را دوست عزیز مون پرسیده اند
بنده یک مقدار بهش جزئیات میدهم
مطابق فیلمها در فایل env
GOOGLE_CLINT_ID=187178020700-gtgbbbqs5t96tai4oq4ldnijgiicfck4.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
GOOGLE_REDIRECT_LINK=http://localhost/Auth/google/callback
این عبارت را
شروع میکنیم به آدرس دادن و همین آدرس را به گوگلhttp://localhost با GOOGLE_REDIRECT_LINK
می دهیم
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
class SocialController extends Controller
{
public function redirectToProvider($driver)
{
//dd($driver);
return Socialite::driver($driver)->redirect();
}
public function callbackProvider($driver)
{
dd($driver);
}
}
و روت مان هم مشابه فیلم ها
Route::get('redirect/{provider}','SocialController@redirectToProvider')->name('Auth.login.provider.redirect');
Route::get('{provider}/callback','SocialController@callbackProvider')->name('Auth.login.provider.callback');
خب روت اول انجام میشود اما روت دوم با
urlاین آدرس
http://localhost/Auth/google/callback?state=sgvFGcQ0tXUufkJTxLNlXcX1mEIBMAgjqBXbZz4n&code=4%2F0AX4XfWgp2Wf054J-4oB-KpcPKOAAJCGjSeb7lAfTeO2baQiUlz7RbBIzIk5dkSZC0AqvyA&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=0&prompt=consent#
این خطا را میدهد
Not Found
The requested URL was not found on this server.
Apache/2.4.46 (Win64) PHP/7.4.9 Server at localhost Port 80
توجه کنید وقتی
url
را تغییر میدهم
http://127.0.0.1:8000/Auth/google/callback?state=sgvFGcQ0tXUufkJTxLNlXcX1mEIBMAgjqBXbZz4n&code=4%2F0AX4XfWgp2Wf054J-4oB-KpcPKOAAJCGjSeb7lAfTeO2baQiUlz7RbBIzIk5dkSZC0AqvyA&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=0&prompt=consent#
به آن خروجی موردنظرم دست پیدا میکنم
با این وجود اومدم
GOOGLE_REDIRECT_LINK=http://127.0.0.1:8000/Auth/google/callback
تغییر دادم و همین ادرس را نیز به گوگل دادم
در روت اول بعد از احراز اصالت گوگل یا قبل از ان این خطا را میدهد
Authorization Error
Error 400: redirect_uri_mismatch
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy.
If you're the app developer, register the redirect URI in the Google Cloud Console.
لطفا راهنمایی کنید.