• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undefined index: expires_in Google API

Good Day I'm trying to study how to integrate google login on my project and it is my first time using this kind of process.
I'm already getting the data which is the given_name, family_name,email, picture and stored in the database.
But after submitting and returning on my redirected page. This error pop up..

A PHP Error was encountered
Severity: Notice

Message: Undefined index: expires_in

Filename: Google/Client.php

Line Number: 470

I don't know where this expired_in coming from. Can someone please help me?? I'm only a student and trying to study for advanced lesson.
I'm using CI v3.
Here's my controller


  $google_client = new Google_Client();

  $google_client->setClientId(''); //Define your ClientID

  $google_client->setClientSecret(''); //Define your Client Secret Key

  $google_client->setRedirectUri(''); //Define your Redirect Uri



   $token = $google_client->fetchAccessTokenWithAuthCode($_GET["code"]);


    $this->session->set_userdata('access_token', $token['access_token']);

    $google_service = new Google_Service_Oauth2($google_client);

    $data = $google_service->userinfo->get();

    $current_datetime = date('Y-m-d H:i:s');

     //update data
     $user_data = array(
      'first_name' => $data['given_name'],
      'last_name'  => $data['family_name'],
      'email_address' => $data['email'],
      'profile_picture'=> $data['picture'],
      'updated_at' => $current_datetime

     $this->google_login_model->Update_user_data($user_data, $data['id']);
    } else {
     //insert data
     $user_data = array(
      'login_oauth_uid' => $data['id'],
      'first_name'  => $data['given_name'],
      'last_name'   => $data['family_name'],
      'email_address'  => $data['email'],
      'profile_picture' => $data['picture'],
      'created_at'  => $current_datetime

    $this->session->set_userdata('user_data', $user_data);

Message: Undefined index: expires_in
Filename: Google/Client.php

check Google/Client.php Line Number: 470

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.