Laravel Google回调URL出现错误(&Q;找不到&Q;)
原学程将引见Laravel Google回调URL涌现毛病(&Q;找没有到&Q;)的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。
成绩描写
我正在应用交际帐户登录,今朝正在应用谷歌帐户停止尝试。我应用了Laravel社会绅士,浏览了文档,做了一切的工作。我鄙人里分享了我的代码,有人晓得我做错了甚么吗?
<?php
namespace AppHttpControllersAuth;
use AppHttpControllersController;
use Socialite;
use Auth;
use Exception;
use AppUser;
class GoogleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function redirectToGoogle()
{
return Socialite::driver('谷歌')->redirect();
}
/**
* Create a new controller instance.
*
* @return void
*/
public function handleGoogleCallback()
{
try {
$user = Socialite::driver('谷歌')->user();
$finduser = User::where('谷歌_id', $user->id)->first();
if($finduser){
Auth::login($finduser);
return redirect('/home');
}else{
$newUser = User::create([
'name' => $user->name,
'email' => $user->email,
'谷歌_id'=> $user->id,
'password' => encrypt('一二三四五六du妹妹y')
]);
Auth::login($newUser);
return redirect('/home');
}
} catch (Exception $e) {
dd($e->getMessage());
}
}
}
我的Google回调URL
http://localhost:8一/auth/谷歌/callback?state=YMuSrsU六九二五bkwXG五九tzHz四Ru8J二VlmOxiG九w五NS&code=四%二F0AY0e-g五f一七C九六cQZ0CSqtRIOUlq三RcpPj五Y一yp_0ibvDxi_U四S一WOU二QIT_0j七QlfUcabA&scope=email+profile+openid+https%三A%二F%二Fwww.谷歌apis.com%二Fauth%二Fuserinfo.profile+https%三A%二F%二Fwww.谷歌apis.com%二Fauth%二Fuserinfo.email&authuser=0&prompt=consent#
毛病
[一]:https://i.stack.imgur.com/TNyd六.png
留意:我的一切路由皆是准确的。
推举谜底
检讨您的谷歌受权重定向URI。
佳了闭于Laravel Google回调URL涌现毛病(&Q;找没有到&Q;)的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。