问题描述
我正在尝试通过我的节点应用程序访问Google上托管的日历,但是由于我的日历需要授权,因此无法通过给定的api查询.
I am trying to access a calendar hosted on google via my node application however I am unable to query it via the given api due to my calendar needing authorisation.
如何禁用此功能/使日历可供我的应用程序访问?
How would I go about disabling this/making the calendar accessible to my application?
这是我的api查询:https://www.googleapis.com/calendar/v3/calendars/heathwallace.com_gpupieshkuc85dd832m9gjrh9g@group.calendar.google.com
Here is my api query:https://www.googleapis.com/calendar/v3/calendars/heathwallace.com_gpupieshkuc85dd832m9gjrh9g@group.calendar.google.com
这是响应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
推荐答案
如果您查看文档日历:例如:您会注意到它的状态
If you check the documentation Calendars: get for example: you will notice it states
现在,通常情况下,如果您将某些内容设置为公共,则可以使用公共API密钥检索它.我将其中一个测试日历设为公开日历,然后尝试使用公共API密钥检索它. (密钥和日历名称均已更改)
Now normally if you set something to public you will be able to retrieve it using a public API key. I took one of my test calendars set it to public then tried to retrieve it using a public API key. (both key and calendar name have been changed)
https://www.googleapis.com/calendar/v3/calendars/tfaf72h2ubfsftl3h4l5qd87s@group.calendar.google.com?key=AIzaSyBBH88dIQPjcl5nIG-n1mmuQ12J7HThDBL
结果是
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
结论:您必须经过身份验证才能检索数据.使用OAuth2或服务帐户.通常,我建议您使用服务帐户并授予其对相关日历的访问权限.由于安全问题,我不会将服务帐户与JavaScript一起使用,因此我无法为您提供帮助.
Conclusion: You must be authenticated to retrieve data. Either using OAuth2 or a service account. Normally I would suggest you use a service account and grant it access to the Calendar in question. I would not use a service account with JavaScript due to security issues, so I cant help you with that.
回答,您的问题必须通过身份验证才能查看日历.没有办法解决.
Answer to your question you must be authenticated to see a calendar. there is no way around that.
这篇关于通过API共享私人Google日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!