Permalink
Browse files

Conform to latest conventions.

  • Loading branch information...
1 parent 6302b9e commit f8cf798b200edfdbd710729f51cd4a73b884061d @jaredhanson committed Feb 16, 2012
Showing with 50 additions and 16 deletions.
  1. +4 −0 .travis.yml
  2. +1 −1 Makefile
  3. +9 −2 README.md
  4. +1 −1 lib/passport-instagram/index.js
  5. +10 −7 lib/passport-instagram/strategy.js
  6. +17 −3 package.json
  7. +8 −2 test/strategy-test.js
View
@@ -0,0 +1,4 @@
+language: "node_js"
+node_js:
+ - 0.4
+ - 0.6
View
@@ -1,5 +1,5 @@
NODE = node
-TEST = vows
+TEST = ./node_modules/.bin/vows
TESTS ?= test/*-test.js
test:
View
@@ -1,7 +1,7 @@
# Passport-Instagram
[Passport](https://github.com/jaredhanson/passport) strategy for authenticating
-with Instagram using the OAuth 2.0 API.
+with [Instagram](http://instagr.am/) using the OAuth 2.0 API.
## Installation
@@ -50,10 +50,17 @@ application:
res.redirect('/');
});
-#### Examples
+## Examples
For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-instagram/tree/master/examples/login).
+## Tests
+
+ $ npm install --dev
+ $ make test
+
+[![Build Status](https://secure.travis-ci.org/jaredhanson/passport-instagram.png)](http://travis-ci.org/jaredhanson/passport-instagram)
+
## Credits
- [Jared Hanson](http://github.com/jaredhanson)
@@ -7,7 +7,7 @@ var Strategy = require('./strategy');
/**
* Framework version.
*/
-exports.version = '0.1.0';
+require('pkginfo')(module, 'version');
/**
* Expose constructors.
@@ -75,18 +75,21 @@ Strategy.prototype.userProfile = function(accessToken, done) {
// the internal node-oauth module will have to be modified to support
// exposing this information.
- this._oauth2.getProtectedResource('https://api.instagram.com/v1/users/self', accessToken, function (err, body, res) {
+ this._oauth2.get('https://api.instagram.com/v1/users/self', accessToken, function (err, body, res) {
if (err) { return done(err); }
try {
- o = JSON.parse(body);
+ var json = JSON.parse(body);
var profile = { provider: 'instagram' };
- profile.id = o.data.id;
- profile.displayName = o.data.full_name;
- profile.name = { familyName: o.data.last_name,
- givenName: o.data.first_name };
- profile.username = o.data.username;
+ profile.id = json.data.id;
+ profile.displayName = json.data.full_name;
+ profile.name = { familyName: json.data.last_name,
+ givenName: json.data.first_name };
+ profile.username = json.data.username;
+
+ profile._raw = body;
+ profile._json = json;
done(null, profile);
} catch(e) {
View
@@ -2,15 +2,29 @@
"name": "passport-instagram",
"version": "0.1.0",
"description": "Instagram authentication strategy for Passport.",
- "author": "Jared Hanson <jaredhanson@gmail.com> (http://www.jaredhanson.net/)",
+ "author": { "name": "Jared Hanson", "email": "jaredhanson@gmail.com", "url": "http://www.jaredhanson.net/" },
"repository": {
"type": "git",
- "url": "http://github.com/jaredhanson/passport-instagram.git"
+ "url": "git://github.com/jaredhanson/passport-instagram.git"
+ },
+ "bugs": {
+ "url": "http://github.com/jaredhanson/passport-instagram/issues"
},
"main": "./lib/passport-instagram",
"dependencies": {
- "passport-oauth": ">= 0.1.0"
+ "pkginfo": "0.2.x",
+ "passport-oauth": "0.1.x"
+ },
+ "devDependencies": {
+ "vows": "0.6.x"
+ },
+ "scripts": {
+ "test": "NODE_PATH=lib node_modules/.bin/vows test/*-test.js"
},
"engines": { "node": ">= 0.4.0" },
+ "licenses": [ {
+ "type": "MIT",
+ "url": "http://www.opensource.org/licenses/MIT"
+ } ],
"keywords": ["passport", "instagram", "auth", "authn", "authentication", "identity"]
}
View
@@ -29,7 +29,7 @@ vows.describe('InstagramStrategy').addBatch({
function() {});
// mock
- strategy._oauth2.getProtectedResource = function(url, accessToken, callback) {
+ strategy._oauth2.get = function(url, accessToken, callback) {
var body = '{"data": { "id": "1574083", "username": "snoopdogg", "full_name": "Snoop Doggy Dogg", "first_name": "Snoop", "last_name": "Dogg", "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg", "bio": "This is my bio", "website": "http://snoopdogg.com", "counts": { "media": 1320, "follows": 420, "followed_by": 3410 } } }';
callback(null, body, undefined);
@@ -61,6 +61,12 @@ vows.describe('InstagramStrategy').addBatch({
assert.equal(profile.name.familyName, 'Dogg');
assert.equal(profile.name.givenName, 'Snoop');
},
+ 'should set raw property' : function(err, profile) {
+ assert.isString(profile._raw);
+ },
+ 'should set json property' : function(err, profile) {
+ assert.isObject(profile._json);
+ },
},
},
@@ -73,7 +79,7 @@ vows.describe('InstagramStrategy').addBatch({
function() {});
// mock
- strategy._oauth2.getProtectedResource = function(url, accessToken, callback) {
+ strategy._oauth2.get = function(url, accessToken, callback) {
callback(new Error('something-went-wrong'));
}

0 comments on commit f8cf798

Please sign in to comment.