Yes, you need to pass the UserIdentity to the callback as a task. Use
.then([]task<UserIdentity^> idtask) { try { auto ident = idtask.get(); ... } catch ... }
instead.