【Google Calendar API v3】get events list with OAuth 2.0 & Rest
来源:互联网 发布:义乌淘宝培训机构 编辑:程序博客网 时间:2024/05/24 07:05
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.1Host: accounts.google.comContent-Type: application/x-www-form-urlencodedcode=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:
- 【Google Calendar API v3】get events list with OAuth 2.0 & Rest
- Github API v3-OAuth
- 使用OAuth 2.0访问Google API
- Youtube api v3 Get list of user's videos
- Github API v3-OAuth Authorizations API
- Google Maps API V3
- google map api v3
- Google Map API V3
- google map api v3
- Google Map API v3
- salesforce rest api 登录 | Authenticating to Salesforce using REST, OAuth 2.0 and Java
- Google Calendar v3授权传参数
- 新建一个分类的api ,Create new magento Rest api to get category list in magento
- google Calendar Api 的使用方法
- google calendar API 插入 event
- google map api V3 随笔..............................
- google map api V3小记
- google map javascript api v3
- XeLaTeX+xeCJK中文字体设置
- Android 焦点问题
- android EditText 自动滚动条并显示最新内容 .
- Ubuntu13.10几分钟自动断网问题(已解决)
- 批量提取文件名bat doc命令
- 【Google Calendar API v3】get events list with OAuth 2.0 & Rest
- SCTP_window7
- 养成6个习惯 预防并克服拖拉,摆脱工作状态不佳的妙方 自我激励法则
- VS2010中 C++创建DLL图解.
- Documentation/usb/bulk-streams.txt
- [备忘]解决apache配置mod_passenger.so permission denied
- 模板技术
- tcp ip状态详解
- HDU 1599 find the mincost route Floyd求最小环