(403) Legacy People API > 之前未在项目 XXXXXXXX 中使用过或者在 Codeigniter 中被禁用
P粉201448898
P粉201448898 2023-08-25 22:54:55
0
1
430
<p>我正在使用 Google 登录,几个月前它可以正常工作,但现在当我尝试登录时,它会出现以下错误:</p> <blockquote> <p>遇到未捕获的异常类型:Google_Service_Exception</p> <p>消息:调用 GET 时出错 https://www.googleapis.com/plus/v1/people/me:(403) 旧版 People API 之前未在项目 XXXXXXXX 中使用过或已禁用。使能够 通过访问它 https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=XXXXXXXX 然后重试。如果您最近启用了此 API,请等待几分钟 传播到我们的系统并重试的操作。</p> </blockquote> <p>访问它显示的链接</p> <pre class="brush:php;toolbar:false;">&quot;Failed to load.&quot; &quot;There was an error while loading /apis/.....googleapis.com/overview?project=&lt;project_id&gt;. Please try again.&quot;</pre> <p>我也启用了 <code>People API</code></p> <p>但仍然收到相同的错误消息</p> <p>我已启用 API:</p> <p>请提供任何解决方案,谢谢</p> <p>代码:</p> <pre class="brush:php;toolbar:false;">&lt;?php require_once('Google/autoload.php'); class Google { protected $CI; public function __construct($url){ $this-&gt;CI =&amp; get_instance(); $this-&gt;CI-&gt;load-&gt;library('session'); $this-&gt;CI-&gt;config-&gt;load('google_config'); $this-&gt;client = new Google_Client(); $this-&gt;client-&gt;setClientId($this-&gt;CI-&gt;config-&gt;item('google_client_id')); $this-&gt;client-&gt;setClientSecret($this-&gt;CI-&gt;config-&gt;item('google_client_secret')); $this-&gt;client-&gt;setRedirectUri($url[0]); $this-&gt;client-&gt;setScopes(array( &quot;https://www.googleapis.com/auth/plus.login&quot;, &quot;https://www.googleapis.com/auth/plus.me&quot;, &quot;https://www.googleapis.com/auth/userinfo.email&quot;, &quot;https://www.googleapis.com/auth/userinfo.profile&quot; ) ); } public function get_login_url(){ return $this-&gt;client-&gt;createAuthUrl(); } public function validate(){ if (isset($_GET['code'])) { $this-&gt;client-&gt;authenticate($_GET['code']); $_SESSION['access_token'] = $this-&gt;client-&gt;getAccessToken(); } if (isset($_SESSION['access_token']) &amp;&amp; $_SESSION['access_token']) { $this-&gt;client-&gt;setAccessToken($_SESSION['access_token']); $plus = new Google_Service_Plus($this-&gt;client); $person = $plus-&gt;people-&gt;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'],&quot;?sz=50&quot;)) . '?sz=800'; return $info; } } }</pre> <blockquote> <p>GoogleConfig.php</p> </blockquote> <pre class="brush:php;toolbar:false;">$config['google_client_id']=&quot;XXXXX.apps.googleusercontent.com&quot;; $config['google_client_secret']=&quot;XXXX&quot;;</pre> <p>控制器:</p> <pre class="brush:php;toolbar:false;">$this-&gt;load-&gt;library('google',array(base_url().$this-&gt;config-&gt;item('google_redirect_url_signin'))); $this-&gt;data['google_redirect_url_signin']=$this-&gt;google-&gt;get_login_url();</pre> <p>查看:</p> <pre class="brush:php;toolbar:false;">&lt;button onclick=&quot;location.href ='&lt;?=$google_redirect_url_signin?&gt;';&quot; class=&quot;loginBtn loginBtn--google&quot;&gt; Login with Google &lt;/button&gt;</pre></p>
P粉201448898
P粉201448898

全部回复(1)
P粉790819727

API 已禁用。

此错误消息是由于 Google Cloud Console 上的项目未启用此 api 造成的一个> .

为什么不启用它是一个我无法回答的问题。

要修复此问题,请转到库下的 Google Cloud Console

搜索人员 API

点击它

然后单击启用按钮,我的显示管理,因为它已经启用。

加载失败

加载失败错误可能意味着两件事。

  1. 有人删除了您在您正在使用的 Google Cloud Console 上使用的项目运行此应用程序。
  2. 有人删除了您对 Google Cloud Console 上的项目的访问权限找出管理员是谁并让他们修复上面的错误。

着火

错误消息让我有点困惑。这似乎暗示您正在使用此端点 https://www.googleapis.com/plus /v1/people/me。我认为所有的 google plus api 端点几年前都被重命名为 people api。您应该使用 people.get 这让我想知道是否谷歌刚刚禁用了您仍在使用的某些东西。

范围

请尝试从您的应用中删除这些范围

它们是旧的 google plus 范围,现在不存在。个人资料和电子邮件应该足够了。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!