我正在尝试向Google日历api发出POST请求,但我不明白如何进行身份验证.
I am trying to issue a POST request towards the google calendar api, but I fail to understand how to authenticate it.
我采取了以下步骤尝试并使用服务帐户来这样做:
I took the following steps to try and use a service account to do so:
我已尝试创建对 www的POST请求.googleapis/calendar/v3/calendars/ calendarId /events,其中JSON密钥的内容作为 Authorization 标头的值,但我收到了以下错误:
I've tried to create a POST request to www.googleapis/calendar/v3/calendars/calendarId/events with the contents of the JSON key as the value of the Authorization header, but I receive the following error:
{错误": {错误":[{"domain":"global","reason":"authError","message":无效的凭证","locationType":"header",位置":授权"}],代码":401,"message":无效的凭据"}}
我是否缺少某些步骤,或者我不正确理解身份验证过程?非常感谢您的帮助.
Am I missing some steps or have I do not understand correctly the authentication process? I would appreciate your help.
推荐答案不仅仅是将密钥文件的内容应用于您的调用,所有Google api都需要访问令牌才能对其进行身份验证.
Its not simply a matter of applying the contents of the key file to your call, all google apis need an access token in order to authenticate them.
要从服务帐户获取访问令牌,您需要执行以下步骤.准备进行授权的API调用
To get an access token from a service account you need to follow the following steps. Preparing to make an authorized API call
您需要完成一些步骤才能获得调用api所需的访问令牌
There are steps you will need to complete inorder to get the access token you will need to make a call to the api
从API控制台获取客户端ID和私钥后,您的应用程序需要完成以下步骤:
After you obtain the client ID and private key from the API Console, your application needs to complete the following steps:
我建议您选择自己喜欢的服务器端编程语言并为其找到客户端库.这样一来,您便可以尝试轻松地使用服务帐户进行身份验证了.
I recommend you pick your favorite server sided programming language and find a client library for it. It will make things much easier then you trying to authncate using a service account by yourself.
更多推荐
通过POST请求进行Google Calendar api身份验证
发布评论