PHP Authorization fail when post in google moment with plusapi PHP Authorization fail when post in google moment with plusapi codeigniter codeigniter

PHP Authorization fail when post in google moment with plusapi


I think you have get authorization error because of following reason -

  1. Not setting email id & project name using developer console link APIs & Auth->Consent Screen.
  2. You are calling deprecated API $this->_CI->googleplus->item_scope->setId($post_data['gp_id']);. To Call this you have to use this class new Google_Service_Plus_ItemScope();
  3. $this->_CI->googleplus->moment_body->setTarget($this->_CI->googleplus->item_scope); .To call this method you have to use this class new Google_Service_Plus_Moment();
  4. I have setup demo code in git for you. Google-Plus-API-Codeigniter-Starter. You can use same code to start with. I have provided detailed instruction in git repository too.
  5. You have to Register your application using Google Console Settings as below:

    • Go to Google Developer Console
    • Create Project
    • To Get Google+ API Access go to: APIs & Auth->APIs -> enable Google+ API
    • To Get client_id & client_secret go to: APIs & Auth->Credentials->Create new Client ID
    • To Get api_key go to: APIs & Auth->Credentials->Create New Key->Browser key
    • To Get application_name go to: APIs & Auth->Consent Screen
      1. Set Email Address
      2. Product Name

Note: Ensure you have get all the required access from google as mentioned in point 5

Conclustion: You are using Latest google-api-php-client client. And trying to call method in an older way. Hence its not working.