       @requestStarredPackages(requestSettings)
     else
       requestSettings.url = "#{config.getAtomApiUrl()}/stars"
-      @getToken (error, token) =>
+      Login.getTokenOrLogin (error, token) =>
         if token?
           requestSettings.headers = authorization: token
           @requestStarredPackages(requestSettings, callback)

      else
        message = body.message ? body.error ? body
        callback("Requesting packages failed: #{message}")

  getToken: (callback) ->
    auth.getToken (error, token) ->
      if error?
        new Login().run({callback, commandArgs: []})
      else
        callback(null, token)

  run: (options) ->
    {callback} = options

_ = require 'underscore-plus'
optimist = require 'optimist'

Command = require './command'
config = require './config'
Install = require './install'
