Google API 错误 401 无效的身份验证凭据 [英] Google API Error 401 invalid authentication credentials

查看:118
本文介绍了Google API 错误 401 无效的身份验证凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Google 的 API.一切正常,突然显示此错误:

I'm working with API of Google. Everything was working fine when suddenly it displays this error:

致命错误:未捕获的 Google_Service_Exception: { "error": { "code": 401, "message": "请求的身份验证凭据无效.需要 OAuth 2 访问令牌、登录 cookie 或其他有效身份验证凭据.

Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.

为了解决这个问题,我不得不创建新的凭据,但问题是错误经常再次出现,这有点烦人,因为我必须重新启动计算机等.

In order to sort this out I had to create new credential but the thing is the error come again often and it is a kind of annoying as I have to reboot the computer,etc..

有人知道我该如何解决这个问题吗?

Anyone know how can i fix this?

编辑

现在我把所有东西都放在一个域名为 .com 的服务器中.我用谷歌验证了域.我更改了凭据.我在 OAuth 2.0 客户端 ID 之前使用过.现在我正在使用 API 密钥.几个小时以来,一切都很好.现在我有同样的错误.

Now I put everything in a server with a domain .com. I verified the domain with google. I changed the credentials. I was using before OAuth 2.0 client IDs . Now I am using API keys. Everything was working fine for hours. Now I have the same error.

有什么想法吗?

推荐答案

[已解决]

在配置(oauth2callback.php 和 API Credentials)中,这是一大堆问题.

it was a bunch o problem, overall in the configuration (oauth2callback.php and API Credentials).

我还必须捕获错误 401 并将其发送到文件 oauth2callback.php.这会生成一个新令牌并将您发送到主页.

As well i had to catch the error 401 and send it to the file oauth2callback.php. This generate a new token and send you to the homepage.

这篇关于Google API 错误 401 无效的身份验证凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆