Correctly cache credentials