访问谷歌日历api时出错

时间:2018-01-23 12:16:07

标签: php google-api

我试图通过谷歌api访问谷歌日历,但收到这样的错误

Type: Google_Service_Exception

Message: Error calling GET 
https://www.googleapis.com/oauth2/v2/userinfo: (401) Invalid Credentials

Filename: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Http/REST.php

Line Number: 110
Backtrace:

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Http/REST.php
Line: 62
Function: decodeHttpResponse

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Task/Runner.php
Line: 174
Function: doExecute

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Http/REST.php
Line: 46
Function: run

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Client.php
Line: 593
Function: execute

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Service/Resource.php
Line: 240
Function: execute

File: /opt/lampp/htdocs/CI/application/third_party/google-api-
php/src/Google/Service/Oauth2.php
Line: 173
Function: call

File: /opt/lampp/htdocs/CI/application/libraries/Googleplus.php
Line: 62
Function: get

File: /opt/lampp/htdocs/CI/application/models/Googlecalendar.php
Line: 83
Function: getUser

File: /opt/lampp/htdocs/CI/application/controllers/Main.php
Line: 17
Function: getUserInfo

File: /opt/lampp/htdocs/CI/index.php
Line: 315
Function: require_once

我完全不知道为什么会收到此错误。我还从Google控制台创建了凭据,但仍未删除。

请帮我解决这个问题。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

  

(401)凭证无效

有三个可能的原因。

  1. 表示您为应用程序使用的客户端ID和客户端分泌不正确。

  2. 同时检查Google开发者控制台,确保您在Google Apis控制台中设置了产品名称和电子邮件地址。

  3. 如果这是一个Web应用程序,请确保您只是尝试使用在Google开发人员控制台上创建项目的用户登录,直到您的项目通过审批流程。