Laravel Google callback url is giving error (quot;Not foundquot;)(Laravel Google回调URL出现错误(Q;找不到Q;))
                            本文介绍了Laravel Google回调URL出现错误(&Q;找不到&Q;)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
我正在使用社交帐户登录,目前正在使用谷歌帐户进行测试。我使用了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('google')->redirect();
    }
      
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function handleGoogleCallback()
    {
        try {
    
            $user = Socialite::driver('google')->user();
     
            $finduser = User::where('google_id', $user->id)->first();
     
            if($finduser){
     
                Auth::login($finduser);
    
                return redirect('/home');
     
            }else{
                $newUser = User::create([
                    'name' => $user->name,
                    'email' => $user->email,
                    'google_id'=> $user->id,
                    'password' => encrypt('123456dummy')
                ]);
    
                Auth::login($newUser);
     
                return redirect('/home');
            }
    
        } catch (Exception $e) {
            dd($e->getMessage());
        }
    }
}
我的Google回调URL
http://localhost:81/auth/google/callback?state=YMuSrsU6925bkwXG59tzHz4Ru8J2VlmOxiG9w5NS&code=4%2F0AY0e-g5f17C96cQZ0CSqtRIOUlq3RcpPj5Y1yp_0ibvDxi_U4S1WOU2QIT_0j7QlfUcabA&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#
错误 [1]:https://i.stack.imgur.com/TNyd6.png
注意:我的所有路由都是正确的。
推荐答案
检查您的谷歌授权重定向URI。
这篇关于Laravel Google回调URL出现错误(&Q;找不到&Q;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:Laravel Google回调URL出现错误(&Q;找不到&Q;)
 
				
         
 
            
        基础教程推荐
             猜你喜欢
        
	     - php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
 
    	 
    	 
    	 
    	 
    	 
    	 
    	 
    	 
				 
				 
				 
				