define(function() {

  function login() {
    var client_id = '2582beb06ed078ba0634',
      scopes = 'user,repo';
    window.location = 'https://github.com/login/oauth/authorize?scopes=' + scopes + '&client_id=' + client_id;
  }

  function getAuth(tokenObj) {
    var gatekeeperUrl = 'http://localhost:9999/authenticate/',
      authCode = getAuthCode(window.location.href);

    getJSON(gatekeeperUrl + authCode, setToken);

    function setToken() {
      tokenObj.token = JSON.parse(this.responseText).token;
    }

    function getAuthCode(url){
      var error = url.match(/[&\?]error=([^&]+)/);
      if (error) {
        throw 'Error getting authorization code: ' + error[1];
      }
      return url.match(/[&\?]code=([\w\/\-]+)/)[1];
    }
  }

  function getJSON(url, cb, headers) {
    var req = new XMLHttpRequest();
    req.addEventListener("load", cb);
    req.open("GET", url);
    if (headers) {
      for (var header in headers) {
        req.setRequestHeader(header, headers[header]);
      }
    }
    req.send();
  }

  return {
    login: login,
    getAuth: getAuth,
    getJSON: getJSON
  }
});


@@ -176,17 +176,16 @@
 ze?scope
-s
 =' + sco
@@ -237,24 +237,21 @@
 ion 
-g
+s
 etAuth
-(t
+T
 oken
-Obj
+(
 ) %7B%0A
@@ -363,16 +363,38 @@
 on.href)
+,%0A      context = this
 ;%0A%0A    g
@@ -474,16 +474,15 @@
     
-tokenObj
+context
 .tok
@@ -1086,24 +1086,34 @@
     
-g
+s
 etAuth
+Token
 : 
-g
+s
 etAuth
+Token
 ,%0A  
@@ -1130,18 +1130,42 @@
  getJSON
+,%0A    token: this.token
 %0A  %7D
+;
 %0A%7D);%0A%0A

fix authorization scope and return token without passing in an object