【GoogleCalendarAPIv3】geteventslistwithOAuth2.0&
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【GoogleCalendarAPIv3】geteventslistwithOAuth2.0&,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2389字,纯文字阅读大概需要4分钟。
内容图文
![【GoogleCalendarAPIv3】geteventslistwithOAuth2.0&](/upload/InfoBanner/zyjiaocheng/564/055ea9bbb9764842804e44ad06a65285.jpg)
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:
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
I use the Chrome Plugin Rest Client to post the request and get access token.
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!
内容总结
以上是互联网集市为您收集整理的【GoogleCalendarAPIv3】geteventslistwithOAuth2.0&全部内容,希望文章能够帮你解决【GoogleCalendarAPIv3】geteventslistwithOAuth2.0&所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。