         deferred.reject(new Error(message))
     deferred.promise
 
+  getExistingToken: (state) =>
+    {user, password, authCode} = state
+    targetAuthorization = @getAuthorization()
+    deferred = Q.defer()
+
+    getAuthorizations = (uri) =>
+      requestOptions =
+        uri: uri
+        method: 'GET'
+        auth:
+          user: user
+          password: password
+          sendImmediately: true
+        json: true
+        proxy: process.env.http_proxy || process.env.https_proxy
+        headers:
+          'User-Agent': @getUserAgent()
+      requestOptions.headers['x-github-otp'] = authCode if authCode
+
+      request requestOptions, (error, {headers, statusCode}={}, body={}) ->
+        if statusCode is 200
+          for authorization in body
+            {token} = authorization
+            authorization = _.pick(authorization, Object.keys(targetAuthorization)...)
+            if _.isEqual(authorization, targetAuthorization)
+              state.token = token
+              deferred.resolve(state)
+              return
+
+          {link} = headers
+          if nextPage = link?.match(/<([^>]+)>;\s*rel\s*=\s*"next"/)?[1]
+            getAuthorizations(nextPage)
+          else
+            deferred.resolve(state)
+        else
+          {message} = body
+          message ?= error.message ? error.code if error
+          deferred.reject(new Error(message))
+
+    getAuthorizations('https://api.github.com/authorizations?per_page=100')
+    deferred.promise
+
+  getAuthorization: ->
+    scopes: ['user', 'repo', 'gist']
+    note: 'Atom Editor'
+    note_url: 'https://atom.io'
+
   createToken: (state) =>
-    {user, password, authCode} = state
+    {user, password, authCode, token} = state
+    return Q(state) if token
+
     requestOptions =
       uri: 'https://api.github.com/authorizations'
       method: 'POST'

    deferred.promise

  saveToken: ({token}) =>
    keytar.replacePassword('Atom GitHub API Token', 'github', token)
    Q(token)

        user: user
        password: password
        sendImmediately: true
      json: @getAuthorization()
      proxy: process.env.http_proxy || process.env.https_proxy
      headers:
        'User-Agent': @getUserAgent()
