Login with google using socialite issue.

This is my controller.

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Socialite;
use Exception;
use Auth;
use URL;
use DB;

class SocialloginController extends Controller
    public function googlelogin() {
        return Socialite::driver('google')->redirect();

    public function callbackgoogle(Request $request) {
        try {
            // $gguser = Socialite::driver('google')->user();
            $gguser = Socialite::driver('google')->stateless()->user();
            echo '<pre>'; print_r($gguser); echo '</pre>'; exit();
        } catch (Exception $e) {
            return redirect('/course')->with('error','Something wrong please try after sometime!');

And below is error when callback from google.

Client error: `POST` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Missing required parameter: code" }

Please help me. Thank you in advance.

Jaydip Patel replied 2 months ago Solution

After a long search, the solution is to remove the 'profile' from scopes in vendor\laravel\socialite\src\Two\GoogleProvider.php

protected $scopes = [
jignesh prajapati replied 9 hours ago

I have already written profile in same file still getting same error can any one help on this ?

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us