Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
57 examples/example-auth.js
@@ -0,0 +1,57 @@
+var gAPI = require('../index').API;
+var fs = require("fs"),
+ util = require("util");
+
+var scope = 'https://www.google.com/m8/feeds/'; //contacts
+
+//put your authentication stuff in 'auth.conf'
+var auth = fs.readFile("./auth.conf", function(err, data){
+ if(data){
+ try{
+ console.log(data.toString());
+ data = JSON.parse(data.toString());
+ }catch(error){
+ err = error;
+ }
+ }
+
+ if(err){
+ console.log("Unable to load config file 'examples/auth.conf'", err);
+ }else{
+ var express = require('express');
+ var app = express();
+ var port = 4000;
+ var page_cb_auth = '/authenticate';
+
+ var api = new gAPI(
+ data.consumer_key,
+ data.consumer_secret,
+ 'http://localhost:'+port+'/authenticate');
+
+ app.get(page_cb_auth, function(req, res){
+ api.gdata.getAccessToken(
+ {
+ scope: scope,
+ access_type: 'offline',
+ approval_prompt: 'force'
+ },
+ req,
+ res,
+ function(err, _token) {
+ if(err) {
+ console.error('oh noes!', err);
+ res.writeHead(500);
+ res.end('error: ' + JSON.stringify(err));
+ } else {
+ token = _token;
+ console.log('got token:', token);
+ res.send(token);
+ }
+ });
+ });
+
+ app.listen(port);
+ }
+
+})
+
View
93 examples/example-get-contacts.js
@@ -0,0 +1,93 @@
+var gAPI = require('../index').API;
+var fs = require("fs"),
+ util = require("util");
+
+var scope = 'https://www.google.com/m8/feeds/'; //contacts
+
+//put your authentication stuff in 'auth.conf'
+var auth = fs.readFile("./auth.conf", function(err, data){
+ if(data){
+ try{
+ console.log(data.toString());
+ data = JSON.parse(data.toString());
+ }catch(error){
+ err = error;
+ }
+ }
+
+ if(err){
+ console.log("Unable to load config file 'examples/auth.conf'", err);
+ }else{
+ var express = require('express');
+ var app = express();
+ var port = 4000;
+ var page_cb_auth = '/authenticate';
+
+ var api = new gAPI(
+ data.consumer_key,
+ data.consumer_secret,
+ 'http://localhost:'+port+'/authenticate');
+
+ api.gdata.setToken(data.token);
+
+ app.get("/", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/contacts/default/full',
+ {'max-results':500,'group':'http://www.google.com/m8/feeds/groups/default/base/6'},
+ function(err, feed) {
+ res.send(feed);
+ });
+ });
+
+ app.get("/groups", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/groups/default/full',
+ {},
+ function(err, feed) {
+ res.send(feed);
+ });
+ });
+
+ app.get("/group/:groupId", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/groups/default/full/'+req.params.groupId,
+ {},
+ function(err, feed) {
+ res.send(feed);
+ });
+ });
+
+ app.get("/", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/contacts/groups/default/full',
+ {},
+ function(err, feed) {
+ res.send(feed);
+ });
+ });
+
+ app.get("/contact/:id", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/contacts/jimi.bailey%40gmail.com/full/'+req.params.id,
+ {},
+ function(err, feed) {
+ console.log("err: ", err);
+ res.send(feed);
+ });
+ });
+
+ app.get("/search/:search", function(req, res){
+ api.gdata.getFeed(
+ 'https://www.google.com/m8/feeds/contacts/default/full',
+ {q:req.params.search},
+ function(err, feed) {
+ console.log(err);
+ res.send(feed);
+ });
+ });
+
+ app.listen(port);
+ }
+
+})
+
View
15 examples/index.js
@@ -1,15 +0,0 @@
-var gOAuth = require('../index');
-
-var express = require('express');
-var app = express();
-var port = 4000;
-
-app.get('/', function(req, res){
- res.send('hello world');
-});
-
-var gOAuth = new OAuth.OAuth2(
- ,
- 'http://localhost:'+port+'/authentication');
-
-app.listen(port);
View
4 index.js
@@ -1,3 +1 @@
-module.exports = function(consumer_key, consumer_secret, callback_uri){
- return new require("./lib/api")(consumer_key, consumer_secret, callback_uri);
-}
+module.exports.API = require("./lib/api");
View
8 lib/api.js
@@ -1,11 +1,11 @@
-var gOAuth = require("google-oauth"),
- request = require("./request");
+var gdata = require('gdata-js'),
+ Request = require("./request");
var API = module.exports = function(consumer_key, consumer_secret, callback_uri){
var self = this;
- self.oauth = new gOAuth(consumer_key, consumer_secret, callback_uri);
+ self.gdata = new gdata(consumer_key, consumer_secret, callback_uri);
//generate the parts to the
- self.request = new Request(self.oauth);
+ self.request = new Request(self.gdata);
}
View
2  package.json
@@ -8,6 +8,6 @@
},
"version": "0.0.1",
"dependencies": {
- "google-oauth":"0.0.2"
+ "gdata-js":"3.0.0"
}
}

No commit comments for this range

Something went wrong with that request. Please try again.