Permalink
Browse files

quick changes

  • Loading branch information...
1 parent 33e9f80 commit dc6fc0ea7afd823296cc8ae9f52e8e6623c92f0d @lyaunzbe committed Jan 5, 2013
Showing with 25 additions and 6 deletions.
  1. +11 −5 index.js
  2. +14 −1 test/test.js
View
@@ -26,9 +26,10 @@ module.exports = function(opts) {
redirect_uri: opts.redirect_uri,
scope: 'https://www.googleapis.com/auth/userinfo.profile'
};
-
- var uri = '\''+endpoint + '?' + querystring.stringify(qs) +'\'';
+ var uri = '\''+endpoint + '?' + querystring.stringify(qs) +'\'';
+
+ //TODO: Make OS agnostic w/ xdg-open, open, etc.
exec('open '+uri, function(err){
if(err !== null){
callback(err);
@@ -57,7 +58,7 @@ module.exports = function(opts) {
*
* @param {String} code The acquired authorization code
*/
- function getTokens(code, callback){
+ function getToken(code, callback){
var uri = 'https://accounts.google.com/o/oauth2/token';
var form = {
code : code,
@@ -76,11 +77,16 @@ module.exports = function(opts) {
});
}
+ /**
+ * Given a refresh token and provided opts, returns a new
+ * access
+ */
+
gAuth.getAuthCode = getAuthCode;
- gAuth.getTokens = getTokens;
+ gAuth.getToken = getToken;
- //gAuth.refreshToken = refreshToken;
+ gAuth.refreshToken = refreshToken;
return gAuth;
View
@@ -26,7 +26,7 @@ describe('Google Oauth', function(){
});
});
- describe('#getTokens()', function(){
+ describe('#getToken()', function(){
it('Respond with access token, refresh token, etc', function(done){
gAuth.getToken(auth_code, function(err, body){
console.log(body);
@@ -38,6 +38,19 @@ describe('Google Oauth', function(){
});
});
+ describe('#getToken()', function(){
+ it('Respond with access token, refresh token, etc', function(done){
+ gAuth.getToken(auth_code, function(err, body){
+ console.log(body);
+ should.not.exist(err);
+ should.exist(body);
+ body.should.be.an('object');
+ done();
+ });
+ });
+ });
+
+
});

0 comments on commit dc6fc0e

Please sign in to comment.