Office365 Activity Fails With CryptographicException

Resolution when Office365 activity fails with Code: generalException Message: An error occurred sending the request.

Error Message: Office365 activities, like GetMail or SendMail can fail with this error message:

  • Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.

---> Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Key not valid for use in specified state. at System.Security.Cryptography.ProtectedData.ProtectOrUnprotect(Byte[] inputData, Byte[] optionalEntropy, DataProtectionScope scope, Boolean protect)



Resolution:

  1. Check is that the Application and its API permissions are correctly configured in Azure, as per Azure Set up documentation.
  2. If the setup is done correctly and the issue persists, navigate to %appdata%/UiPath/authentication and delete the contents of this folder.
  3. If multiple Robots are present running on the same server, like in a High-Density setup, do the same deletion from the folder of any affected Robot account.