           return unless token
           @saveToken token
           Spine.trigger 'login' if @token
+    else if window.cordova
+      if window.device.platform.indexOf('Android')!=-1
+        navigator.app.loadUrl @::oauthEndPoint
+      else
+        window.location = @::oauthEndPoint
     else
       window.location = @::oauthEndPoint
 

    @token

  @logout: ->
    @deleteToken()
    window.location.reload()
    if window.cordova
      window.location = Config.oauthEndpoint.replace('/oauth/','/accounts/sign_out/')
    else if window.forge
      forge.tabs.openWithOptions
        url: Config.oauthEndpoint.replace('/oauth/','/accounts/sign_out/')

  oauthEndPoint: "#{Config.oauthEndpoint}authorize?client_id=#{@::clientId}&response_type=token&redirect_uri=#{Config.oauthRedirectUri}"

  @setup: ->
    $(document).on 'ajaxError', (event, xhr, ajaxSettings, thrownError) =>
      console.log("Global ajaxError", arguments)
      console.log("XHR.status", xhr.status)
      console.log("XHR.responseText", xhr.responseText)
