目录
Step 1.  Send an Authentication Request to Google
Step 3. Get Events List NOW!
首页 数据库 mysql教程 【Google Calendar API v3】get events list with OAuth 2.0 &

【Google Calendar API v3】get events list with OAuth 2.0 &

Jun 07, 2016 pm 03:43 PM
api calendar events get google

It took me some time to learn about the Google Calendar API V3 and I have encountered some problems. So it is necessary to summary the steps, just take the 'event list' as an example. The event list API is here:https://developers.google.co

It took me some time to learn about the Google Calendar API V3 and I have encountered some problems. So it is necessary to summary the steps, just take the 'event list' as an example.


The event list API is here: https://developers.google.com/google-apps/calendar/v3/reference/events/list


Details of using OAuth 2.0 for Login is here: https://developers.google.com/accounts/docs/OAuth2Login


Assumption: you have alreay registered your app and turn the Calendar API 'ON' in the 'API & auth' sidebar.


Note: The request needs authorization and I use OAuth 2.0, here are the steps.


Step 1.  Send an Authentication Request to Google

HTTP GET: https://accounts.google.com/o/oauth2/auth?

client_id=XXXXXXXXX&

response_type=code&

scope=https://www.googleapis.com/auth/calendar&

redirect_uri=XXXXXXXXX&

login_hint=XXXXXX


client_id: can be seen in your Google Cloud Console.

redirect_uri: also in your Google Cloud Console, you must write it down in your registered apps page.

login_hint=google account


Then your will find the code parameter in the redirect uri.


Step 2. Exchange Code for Access Token and ID Token

Use the code you got in the last step to post request. The actual request might look like:

<span>POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded

code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=8819981768.apps.googleusercontent.com&
client_secret={client_secret}&
redirect_uri=https://oauth2-login-demo.appspot.com/code&
grant_type=authorization_code</span>
登录后复制

I use the Chrome Plugin Rest Client to post the request and get access token.

【Google Calendar API v3】get events list with OAuth 2.0 &

Then you will get the access_token in the response.


Step 3. Get Events List NOW!

With the access_token, you are able to request the event list according to Google Calendar API.
The whole HTTP GET URI is like:


https://www.googleapis.com/calendar/v3/calendars/{your calendar id}/events?

code=XXXXXX&

client_id=XXXXXX&

client_secret=XXXXXX&

redirect_uri=XXXXX&

grant_type=authorization_code

&access_token=XXXXXXXX


{your calendar id} is your google account, looks like XXX@gmail.com


Then you will get the JSON response!


本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

据传 Google Pixel 9 和 Pixel 9 Pro 将在发布时配备 Creative Assistant AI 据传 Google Pixel 9 和 Pixel 9 Pro 将在发布时配备 Creative Assistant AI Jun 22, 2024 am 10:50 AM

目前,四款新 Pixel 智能手机预计将于今年秋季上市。回顾一下,据传该系列将在发布时推出 Pixel 9 和 Pixel 9 Pro。然而,Pixel 9 Pro 将成为 iPhone 16 Pro 的竞争对手,而不是 Pixel 8 Pro(目前)

谷歌 Pixel 9 Pro XL 接受桌面模式测试 谷歌 Pixel 9 Pro XL 接受桌面模式测试 Aug 29, 2024 pm 01:09 PM

谷歌在 Pixel 8 系列中引入了 DisplayPort 替代模式,并且在新推出的 Pixel 9 系列中也采用了该模式。虽然它主要是为了让您通过连接的屏幕镜像智能手机显示,但您也可以将其用于桌面

Pixel 9 Pro XL 的 Google Tensor G4 在 原神 方面落后于 Tensor G2 Pixel 9 Pro XL 的 Google Tensor G4 在 原神 方面落后于 Tensor G2 Aug 24, 2024 am 06:43 AM

谷歌最近回应了有关 Pixel 9 系列 Tensor G4 性能的担忧。该公司表示,该 SoC 的设计初衷并不是为了超越基准。相反,该团队专注于使其在 Google 想要的领域表现良好。

Google AI 为开发者发布 Gemini 1.5 Pro 和 Gemma 2 Google AI 为开发者发布 Gemini 1.5 Pro 和 Gemma 2 Jul 01, 2024 am 07:22 AM

从 Gemini 1.5 Pro 大语言模型 (LLM) 开始,Google AI 已开始为开发人员提供扩展上下文窗口和节省成本的功能。以前可通过等候名单获得完整的 200 万个代币上下文窗口

谷歌应用测试版 APK 拆解揭示 Gemini AI 助手即将推出新扩展 谷歌应用测试版 APK 拆解揭示 Gemini AI 助手即将推出新扩展 Jul 30, 2024 pm 01:06 PM

如果考虑最新更新(v15.29.34.29 beta)的 APK 拆解,谷歌的人工智能助手 Gemini 将变得更加强大。据报道,这家科技巨头的新人工智能助手可能会获得一些新的扩展。这些扩展

尽管做出了七年更新承诺,谷歌 Pixel 9 智能手机仍不会搭载 Android 15 尽管做出了七年更新承诺,谷歌 Pixel 9 智能手机仍不会搭载 Android 15 Aug 01, 2024 pm 02:56 PM

Pixel 9 系列即将发布,原定于 8 月 13 日发布。根据最近的传言,Pixel 9、Pixel 9 Pro 和 Pixel 9 Pro XL 将与 Pixel 8 和 Pixel 8 Pro(亚马逊售价 749 美元)一样,配备 128 GB 存储空间。

新的 Google Pixel 桌面模式在新鲜视频中展示,可能是 Motorola Ready For 和 Samsung DeX 的替代方案 新的 Google Pixel 桌面模式在新鲜视频中展示,可能是 Motorola Ready For 和 Samsung DeX 的替代方案 Aug 08, 2024 pm 03:05 PM

自从 Android Authority 展示谷歌隐藏在 Android 14 QPR3 Beta 2.1 中的新 Android 桌面模式以来,已经过去了几个月。紧随 Google 为 Pixel 8 和 Pixel 8 添加 DisplayPort Alt 模式支持之后

泄露的 Google Pixel 9 广告展示了新的人工智能功能,包括'添加我”相机功能 泄露的 Google Pixel 9 广告展示了新的人工智能功能,包括'添加我”相机功能 Jul 30, 2024 am 11:18 AM

更多与 Pixel 9 系列相关的宣传材料已在网上泄露。作为参考,在 91mobiles 分享多张图片后不久,新的泄漏事件也出现了,其中还展示了 Pixel Buds Pro 2 和 Pixel Watch 3 或 Pixel Watch 3 XL。这次

See all articles