HTTP status 401: Unauthorized errors
If you are a victim of “HTTP status 401: Unauthorized error” then please try the following tip. It may work for you.
To cache the credential of users PreAuthenticate property of both CRMService and MetadataService is used. But sometimes this behavior causes “HTTP status 401: Unauthorized errors” Error. Therefore, Microsoft recommends avoiding the PreAuthenticate property in your code at this time.