Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 791e07a

Browse files
author
arthurthompson
committed
Add Google Calendar API sample.
1 parent 49d45a6 commit 791e07a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

samples/calendar_api/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Loop over all a user's calendars, printing their titles.
2+
3+
api: calendar
4+
keywords: cmdline pagination
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2014 Google Inc. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
"""Simple command-line sample for the Calendar API.
19+
Command-line application that retrieves the list of the user's calendars."""
20+
21+
import sys
22+
23+
from oauth2client import client
24+
from googleapiclient import sample_tools
25+
26+
def main(argv):
27+
# Authenticate and construct service.
28+
service, flags = sample_tools.init(
29+
argv, 'calendar', 'v3', __doc__, __file__,
30+
scope='https://www.googleapis.com/auth/calendar.readonly')
31+
32+
try:
33+
page_token = None
34+
while True:
35+
calendar_list = service.calendarList().list(pageToken=page_token).execute()
36+
for calendar_list_entry in calendar_list['items']:
37+
print calendar_list_entry['summary']
38+
page_token = calendar_list.get('nextPageToken')
39+
if not page_token:
40+
break
41+
42+
except client.AccessTokenRefreshError:
43+
print ('The credentials have been revoked or expired, please re-run'
44+
'the application to re-authorize.')
45+
46+
if __name__ == '__main__':
47+
main(sys.argv)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"installed": {
3+
"client_id": "[[INSERT CLIENT ID HERE]]",
4+
"client_secret": "[[INSERT CLIENT SECRET HERE]]",
5+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
6+
"token_uri": "https://accounts.google.com/o/oauth2/token",
7+
"client_email": "",
8+
"redirect_uris": [
9+
"urn:ietf:wg:oauth:2.0:oob",
10+
"oob"
11+
],
12+
"client_x509_cert_url": "",
13+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
14+
}
15+
}

0 commit comments

Comments
 (0)