Back

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 https://accounts.google.com/o/oauth2/token` 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 6 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 = [
    'openid',
    'email',
];
jignesh prajapati replied 3 months ago

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

Bryan Ruffin replied 3 months ago

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to. Also, operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, I'm always looking for people to check out my web site. fireboy and watergirl


Sign in to participate in this thread!



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