Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gdata-js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gdata-js - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

31

gdata.js

@@ -14,15 +14,19 @@ var querystring = require('querystring');

var token;
var client = new EventEmitter();
client.getAccessToken = function(scope, req, res, callback) {
client.getAccessToken = function(options, req, res, callback) {
if(req.query.error) {
callback(req.query.error);
} else if(!req.query.code) {
options.client_id = clientID;
options.redirect_uri = options.redirect_uri || redirectURI;
options.response_type = 'code';
var height = 750;
var width = 980;
resp = "<script type='text/javascript'>var left= (screen.width / 2) - (" + width + " / 2); var top = (screen.height / 2) - (" + height + " / 2); window.open('" + oauthBase + '/auth?' + querystring.stringify({client_id: clientID, redirect_uri: redirectURI, scope: scope, response_type: 'code'}) + "', 'auth', 'menubar=no,toolbar=no,status=no,width=" + width + ",height=" + height + ",toolbar=no,left=' + left + 'top=' + top);</script>";
res.end(resp + '<a target=_new href=\'' + oauthBase + '/auth?' + querystring.stringify({client_id: clientID ,
redirect_uri: redirectURI,
scope: scope,
response_type: 'code'}) + '\'>Authenticate</a>');
resp = "<script type='text/javascript'>" +
"var left= (screen.width / 2) - (" + width + " / 2);" +
"var top = (screen.height / 2) - (" + height + " / 2);" +
"window.open('" + oauthBase + '/auth?' + querystring.stringify(options) + "', 'auth', 'menubar=no,toolbar=no,status=no,width=" + width + ",height=" + height + ",toolbar=no,left=' + left + 'top=' + top);" +
"</script>";
res.end(resp + '<a target=_new href=\'' + oauthBase + '/auth?' + querystring.stringify(options) + '\'>Authenticate</a>');
} else {

@@ -40,6 +44,7 @@ doPost({grant_type:'authorization_code',

}
client.setToken = function(tkn) {
token = tkn;
}
client.getFeed = function(url, params, callback) {

@@ -57,4 +62,4 @@ if(!callback && typeof params === 'function') {

};
function doRequest(url, params, callback) {

@@ -98,3 +103,3 @@ var path = URL.parse(url).pathname + '?' + querystring.stringify(params);

}
function refreshToken(callback) {

@@ -113,2 +118,6 @@ doPost({client_id:clientID,

}
//for debugging
client._refreshToken = refreshToken;
return client;

@@ -115,0 +124,0 @@ }

{
"name": "gdata-js",
"description": "Simple OAuth 2.0 GData API client",
"version": "1.0.0",
"version": "2.0.0",
"author": "Simon Murtha-Smith <simon@murtha-smith.com>",

@@ -6,0 +6,0 @@ "keywords": ["google", "gdata"],

@@ -5,4 +5,11 @@ var request = require('request');

var clientID = process.argv[2];
var clientSecret = process.argv[3];
if (! (clientID && clientSecret) ) {
console.error('usage: node test.js <clientID> <clientSecret>');
process.exit(1);
}
// get an clientID and clientSecret at https://code.google.com/apis/console/
var gdataClient = require('./gdata')('680845003810.apps.googleusercontent.com', 'Zl8-p4_wqNEZlgElr0VWH4Zn', 'http://localhost:8553/')
var gdataClient = require('./gdata')(clientID, clientSecret, 'http://localhost:8553/');
var scope = 'https://www.google.com/m8/feeds/'; //contacts

@@ -13,5 +20,8 @@

app = express.createServer(connect.bodyParser());
app.get('/', function (req, res) {
gdataClient.getAccessToken(scope, req, res, function(err, token) {
// see https://developers.google.com/accounts/docs/OAuth2WebServer for options
gdataClient.getAccessToken({scope: scope,
access_type: 'offline',
approval_prompt: 'force'}, req, res, function(err, token) {
if(err) {

@@ -18,0 +28,0 @@ console.error('oh noes!', err);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc