def lock
      auth_state_model.transaction do
        record = auth_state_model.
          lock(true).
          find(authentication.id)

        yield record

        record
      end
    end
def lock
      auth_state_model.transaction do
        record = auth_state_model.
          lock(true).
          find(authentication.id)

        yield record

        record
      end
    end
The authentication parameter must be either a string (indicating
 a token), or an object that responds to:
   - #id
   - #token
   - #update(hash) -- which should update #token with hash[:token]:noh
 Obtains a lock (via the API.auth_state_model interface) and
 yields an authentication object corresponding to
 self.authentication.id. The object is returned when the block
 finishes.