Fix incorrect handling of expired credentials.