This is racy; a crash after deleting the old token but before saving the new token could leave the user unable to log in.  Can we fix that by doing these operations in a different order, e.g. write the new data before deleting the old?

Not necessarily something to fix straight away, but something to think about.