Permalink
Browse files

Edit document (README.md)

  • Loading branch information...
1 parent a03d51d commit 93459f4bab945a77d43fcef70a2d8d1064fd4d90 @wanasit committed Nov 2, 2012
Showing with 83 additions and 7 deletions.
  1. +79 −3 README.md
  2. +4 −4 package.json
View
@@ -4,12 +4,10 @@ Google-Calendar
Google Calendar Connection for Node.js
-
Installation
=======
-To install the most recent release from npm, run:
-
+To install from npm, run:
```shell
npm install google-calendar
@@ -27,5 +25,83 @@ var google_calendar = new GoogleCalendar.GoogleCalendar(
```
+OAuth Authentication
+=======
+
+This module includes [google-oauht](https://github.com/berryboy/google-oauth) for OAuth 2.0 authentication.
+If you use framework such as [express](git://github.com/visionmedia/express), you can create OAuht authentication by following :
+
+```javascript
+
+app.all('/authentication', function(req, res){
+
+ if(!req.query.code){
+
+ //Redirect the user to Google's authentication form
+ google_calendar.getGoogleAuthorizeTokenURL(function(err, redirecUrl) {
+ if(err) return res.send(500,err);
+ return res.redirect(redirecUrl);
+ });
+
+ }else{
+ //Get access_token from the code
+ google_calendar.getGoogleAccessToken(req.query, function(err, access_token, refresh_token) {
+
+ if(err) return res.send(500,err);
+
+ req.session.access_token = access_token;
+ req.session.refresh_token = refresh_token;
+ return res.redirect('/');
+ });
+ }
+});
+
+```
+
+Google Calendar Usage
+=======
+
+This module (try to) follows [Google Calendar API Reference](https://developers.google.com/google-apps/calendar/v3/reference/).
+
+
+```javascript
+
+//CalendarList.list
+google_calendar.listCalendarList(access_token, function(err, calendarList) {
+
+ calendarList.items.forEach(function(calendar) {
+
+ //Events.list
+ google_calendar.listEvent(access_token, calendar.id, function(err, events) {
+
+ console.log('Calendar : ' + calendar.summary)
+ events.items.forEach(function(event) {
+ console.log('> ' + event.summary)
+ });
+ });
+ });
+});
+
+```
+
+Implemented Methods List
+=======
+
+Calendar List
+
+- GoogleCalendar.listCalendarList = function(access_token, option, callback)
+
+- GoogleCalendar.getCalendarList = function(access_token, calendarId, callback)
+
+Events
+
+- GoogleCalendar.listEvent = function(access_token, calendarId, option, callback)
+
+- GoogleCalendar.insertEvent = function(access_token, calendarId, event, option, callback)
+
+- GoogleCalendar.getEvent = function(access_token, calendarId, eventId, option, callback)
+
+- GoogleCalendar.deleteEvent = function(access_token, calendarId, eventId, option, callback)
+- GoogleCalendar.updateEvent = function(access_token, calendarId, eventId, event, option, callback)
View
@@ -6,11 +6,11 @@
"type" : "git",
"url" : "https://github.com/berryboy/google-calendar"
},
- "version": "0.0.2",
+ "version": "0.0.3",
"main": "./GoogleCalendar",
"dependencies": {
- "restler": "lastest",
- "express":"latest",
- "google-oauth":"latest"
+ "restler": "2.0.1",
+ "express":"2.5.9",
+ "google-oauth":"0.0.2"
}
}

0 comments on commit 93459f4

Please sign in to comment.