HTTP GET: Get Google Calendar Event List via Google Calendar API v3 - invalid key error

 ̄綄美尐妖づ 提交于 2019-12-06 05:54:38

Usually this error is thrown when the key used in the request is invalid. In the request you have to use the public key not the client secret(when you want to send the API key). Here is the link for the documentation on how to get the public key to your application.

Also,here is the link for documentation about the HTTP request for events get request.

To anyone trying to achieve the same and who's not in the need to use API v3 at any cost:

There is still an option to get future events with a request similar to API v2. Therefore, use the private XML-code from the calendar settings and add the parameters you need. E.g.:

HTTP GET http://www.google.com/calendar/feeds/your_email/private-validation/basic?futureevents=true&max-results=1&singleevents=true&orderby=starttime&sortorder=ascending

I could not find any up-to-date documentation from Google about this but it's working. The main difference to API v2 is the "/basic?" at the end instead of the old "/full?". Otherwise most parameters seem to work fine.

futureevents=true - only shows future events
max-results=integer - only show integer number of results
singleevents=true - handly reoccuring events as single events
orderby=starttime - sort results by their starting time instead of last update
sortorder=ascending - well, sort order

"printpretty" seems not to be supported anymore. Also, the timestamp has a different look now. But still, all the information needed is included.

The example above shows the request for the next event in the calendar. This may be extended to multiple events (e.g. max-results=5). The other parameters are needed to show up the next events as expected instead of some seemingly random events. The problem with this method is of course that your private adress is used in the request which may be insecure in comparison to API v3.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!