Google Calendar API错误-"API密钥无效.请传递一个有效的API密钥.", [英] Google Calendar API error - "API key not valid. Please pass a valid API key.",

查看:318
本文介绍了Google Calendar API错误-"API密钥无效.请传递一个有效的API密钥.",的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从昨天开始,我已经开始从Google Rest API收到错误消息

I've started getting the error from google rest api since yesterday

{
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "errors": [
      {
        "message": "API key not valid. Please pass a valid API key.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

API端点是: 标题为:

"Content-length"    "0"
"Content-Type"  "application/x-www-form-urlencoded"
"Host"  "www.googleapis.com"
"Authorization" "Bearer [APPILCATION_ID]"
"Accept"    "application/json"

我在开发人员控制台中有oAuth 2.0客户端ID. 并发送与3个月前相同的请求 可能是什么问题?

I have oAuth 2.0 client id in developer console. And send the same request as 3 month before What may be wrong?

推荐答案

API密钥无效.请传递有效的API密钥.

API key not valid. Please pass a valid API key.

表示您使用的api密钥无效.

Means that the api key you are using is not valid.

转到 Google开发者控制台选择您的项目.

点击左侧菜单中的凭据

点击顶部的+创建凭据,然后选择API密钥.

click the + create credentials at the top and select API key.

授权" 承载者[APPILCATION_ID]"

"Authorization" "Bearer [APPILCATION_ID]"

请不要发送的承载令牌应该是有效的未过期访问令牌.不是应用程序ID.

Please not that the bearer token sent should be a valid non expired access token. Not an application id.

Api键用于访问公共数据,就像所有假日日历一样,如果您希望能够从中请求数据,请确保将您尝试访问的日历ID设置为公共.

Api keys are used for accessing public data like all the holiday calendars make sure that the calendar id you are trying to access is set to public if you want to be able to request data from it.

如果这是用户日历,则需要切换为使用Oauth2,并要求他们授予您访问其数据的权限.

If this is a user calendar you will need to switch to using Oauth2 and request that they grant you permission to access their data.

如果这是您自己的日历,并且您希望允许其他人查看数据,那么您应该考虑使用服务帐户.

If this is your own calendar and you want to allow others to see the data then you should consider using a service account.

这篇关于Google Calendar API错误-"API密钥无效.请传递一个有效的API密钥.",的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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