laravel / socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Home Page:https://laravel.com/docs/socialite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade Version

cheadevit opened this issue · comments

Socialite Version

5.5.8

Laravel Version

9.52.15

PHP Version

8.1.16

Database Driver & Version

mysql v8.0.32

Description

Here

I'm trying to upgrade Laravel to 9 from 8, and I also upgrade the Socialite version to 5.5.8 from 5.2.

Steps To Reproduce

Here is my Controller,

<?php

namespace App\Http\Controllers;
use Laravel\Socialite\Facades\Socialite;
use Exception;
use App\Models\User;
use Illuminate\Support\Facades\Auth;

class GoogleController extends Controller
{
    public function redirectToGoogle()
    {
        return Socialite::driver('google')->redirect();
    }
        
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function handleGoogleCallback()
    {
        try {
            $user = Socialite::driver('google')->user();

            if (explode("@", $user->email)[1] != 'example.com'){
                return redirect()->route('backpack.auth.login')->with('error','Accout Not Allow');
            }

            $finduser = User::where('email', '=', $user->email)->first();
       
            if(isset($finduser) == true){
       
                $updateUser = User::where('email', '=', $user->email)->update([
                    'email' => $user->email,
                    'google_id'=> $user->id,
                ]);

                Auth::login($finduser);
      
                return redirect()->intended('admin/dashboard');
       
            }else{
                $newUser = User::create([
                    'name' => $user->name,
                    'email' => $user->email,
                    'google_id'=> $user->id,
                    'password' => encrypt('*****')
                ]);

                $newUser->assignRole(2);

                Auth::login($newUser);
      
                return redirect()->intended('admin/dashboard');
            }
      
        } catch (Exception $e) {
            dd($e->getMessage());
        }
    }
}

Error message:

"cURL error 6: getaddrinfo() thread failed to start (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.googleapis.com/oauth2/v4/token"

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out.

Thanks!