           else
             try {errors} = JSON.parse request.responseText
 
+          console?.error 'Failed to sign in', errors
           Promise.reject errors
 
     @currentUser

  _getBearerToken: ->
    console?.log 'Getting bearer token'
    if @bearerToken
      console?.log 'Already had a bearer token', @bearerToken
      Promise.resolve @bearerToken
    else
      data =
        grant_type: 'password'
        client_id: config.clientAppID

      console?.log 'Requesting a new bearer token'
      makeHTTPRequest 'POST', config.host + '/oauth/token', data, JSON_HEADERS
        .then (request) =>
          response = JSON.parse request.responseText
          @bearerToken = response.access_token
          client.headers['Authorization'] = "Bearer #{@bearerToken}"
          console?.log 'Got bearer token', @bearerToken
          @bearerToken

        .catch (request) ->

      .then (request) ->
        [_, authTokenMatch1, authTokenMatch2] = request.responseText.match CSRF_TOKEN_PATTERN
        authToken = authTokenMatch1 ? authTokenMatch2
        console?.info 'Got auth token', authToken
        authToken

      .catch (request) ->
        # The back end is down or something.
        try {errors} = JSON.parse request.responseText
        errors ?= [message: password: ['Could not connect to the server']]

