Error requesting the refresh_token when integrating the Google Drive API with Laravel


+4 days ago I implemented the registration and login through Google in my Laravel application.

When the user does not have an account then it is created, but when it is already registered what it does is allow access.

public function handleProviderGoogleCallback()
      $auth_user = Socialite::driver('google')->stateless()->user();

        $user = User::firstOrCreate(
                'email' => $auth_user->email
                'refresh_token' => $auth_user->refreshToken,
                'name'  =>  $auth_user->name


        return redirect()->to('/home')->with('info', "Bienvenido " . $user->name); //

So far so good, the problem is when I will access the route to see my files. Since I get this error.

I did everything following this tutorial: link

I have tried to speak with the author, but it is not possible for me to respond.

I appreciate the guidance. Thank you very much

asked by Brayan Angarita 09.09.2018 в 05:05

1 answer


Finally I was able to solve the problem.

What happened was that Socialite did not allow me to get the refresh_token and that's why I was sending a null value. So I changed the line 'refresh_token' => $auth_user->refreshToken, by 'refresh_token' => $auth_user->token, ...

I had to do that because I only returned the token that is used to login. After changing that, it worked for me, and I managed to consume the Google Drive API.

answered by 16.09.2018 / 20:20