Home  >  Q&A  >  body text

(403) Legacy People API > has not been used before in project XXXXXXXX or is disabled in Codeigniter

<p>I'm using Google login and it was working fine a few months ago, but now when I try to log in it gives the following error: </p> <blockquote> <p>Uncaught exception type encountered: Google_Service_Exception</p> <p>Message: Error while calling GET https://www.googleapis.com/plus/v1/people/me: (403) Old version of People API Not previously used in project XXXXXXXX or disabled. enable access it via https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=XXXXXXXX Then try again. If you recently enabled this API, please wait a few minutes propagate to our system and retry the operation.</p> </blockquote> <p>Visit the link it displays</p> <pre class="brush:php;toolbar:false;">"Failed to load." "There was an error while loading /apis/....googleapis.com/overview?project=<project_id>. Please try again."</pre> <p>I also enabled the <code>People API</code></p> <p>But still getting the same error message</p> <p>I have enabled the API: </p> <p>Please provide any solution, thank you</p> <p>Code:</p> <pre class="brush:php;toolbar:false;"><?php require_once('Google/autoload.php'); class Google { protected $CI; public function __construct($url){ $this->CI =& get_instance(); $this->CI->load->library('session'); $this->CI->config->load('google_config'); $this->client = new Google_Client(); $this->client->setClientId($this->CI->config->item('google_client_id')); $this->client->setClientSecret($this->CI->config->item('google_client_secret')); $this->client->setRedirectUri($url[0]); $this->client->setScopes(array( "https://www.googleapis.com/auth/plus.login", "https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" ) ); } public function get_login_url(){ return $this->client->createAuthUrl(); } public function validate(){ if (isset($_GET['code'])) { $this->client->authenticate($_GET['code']); $_SESSION['access_token'] = $this->client->getAccessToken(); } if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $this->client->setAccessToken($_SESSION['access_token']); $plus = new Google_Service_Plus($this->client); $person = $plus->people->get('me'); $info['id']=$person['id']; $info['email']=$person['emails'][0]['value']; $info['name']=$person['displayName']; $info['link']=$person['url']; $info['profile_pic']=substr($person['image']['url'],0,strpos($person['image']['url'],"?sz=50")) . '?sz=800'; return $info; } } }</pre> <blockquote> <p>GoogleConfig.php</p> </blockquote> <pre class="brush:php;toolbar:false;">$config['google_client_id']="XXXXX.apps.googleusercontent.com"; $config['google_client_secret']="XXXX";</pre> <p>控制器:</p> <pre class="brush:php;toolbar:false;">$this->load->library('google',array(base_url().$this->config->item('google_redirect_url_signin'))); $this->data['google_redirect_url_signin']=$this->google->get_login_url();</pre> <p>查看:</p> <pre class="brush:php;toolbar:false;"><button onclick="location.href ='<?=$google_redirect_url_signin?>';" class="loginBtn loginBtn--google"> Login with Google </button></pre></p>
P粉201448898P粉201448898393 days ago556

reply all(1)I'll reply

  • P粉790819727

    P粉7908197272023-08-26 20:10:13

    API is disabled.

    This error message is due to Google Cloud Console .

    Why it's not enabled is a question I can't answer.

    To fix this issue, go to Google Cloud Console

    under Libraries

    Search Personnel API

    click it

    Then click the Enable button to show my management as it is already enabled.

    Failed to load

    Load failed errors can mean two things.

    1. Someone deleted the project you were using on the Google Cloud Console you are using to run this application.
    2. Someone removed your access to a project on Google Cloud Console Find out who the administrator is and have them fix the error above.

    on fire

    The error message confuses me a bit. This seems to imply that you are using this endpoint https://www.googleapis.com/plus /v1/people/me. I think all the google plus api endpoints were renamed to people api a few years ago. You should use people.get This makes me wonder if Google just disabled something you are still using.

    scope

    Please try removing these scopes from your app

    They are old google plus scopes that don't exist now. Personal details and email should be enough.

    reply
    0
  • Cancelreply