Welcome Guest, Not a member yet? Register   Sign In
Call to undefined method CodeIgniter\HTTP\IncomingRequest::get()
#1

Hi, Please help with following error not sure how to resolve it. 

I am implementing signin with google on my ci4 project. I get Call to undefined method CodeIgniter\HTTP\IncomingRequest::get() when i try to retrieve user data from google service response. Below is my code. Thanks in advance. 

PHP Code:
public function index()
 {
 
$data =[];
 
$google_client = new \Google_Client();
 
$google_client->setClientId('clientID.apps.googleusercontent.com');
 
$google_client->setClientSecret('my-secret');
 
$google_client->setRedirectUri(base_url());
 
$google_client->addScope('email');
 
$google_client->addScope('profile');
 
 if(
$this->request->getVar('code')){
 
$token $google_client->fetchAccessTokenWithAuthCode($this->request->get('code'));
 
 if(!
$token['error']){
 
$google_client->setAccessToken($token['access_token']);

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

 
//get profile data
 
$google_service = new \Google_Service_0auth2($google_client);
 
 
//This is where i get the error
 
$data $google_service->userinfo->get();
 
 

 }
 }

 if(!
session()->get('access_token')){
 
$data['login_button'] = $google_client->createAuthUrl();
 }
 return 
view('login',$data);
 
 } 
Reply
#2

Hi, try

$this->request->getGet()['code']
Reply




Theme © iAndrew 2016 - Forum software by © MyBB