简体   繁体   中英

ErrorException Object of class Laravel\Socialite\Two\User could not be converted to string

I am trying to implement socialite in laravel

When the redirect happens from google and $user = Socialite::driver('google')->stateless()->user(); instruction is called i get this error

ErrorException Object of class Laravel\Socialite\Two\User could not be converted to string

any help appreciated.

here is my code

public function redirectToProvider()
    {
        return Socialite::driver('google')->redirect();


    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleProviderCallback(Request $request)
    {
        \Log::Info("handleProviderCallback");
        $query = $request->query();
        \Log::Info($query);
        $user = Socialite::driver('google')->stateless()->user();
        \Log::Info($user);

        // $user->token;    
    }
\Log::Info($user);

This needs string not object. You are passing an object instead of a string.

info(print_r($user,true));

show all the detail with laravel helper function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM