0

I'm developing an API consuming Dynamics CRM through Microsoft.PowerPlatform.Dataverse.Client.

When invoking ExecuteAsync on the ServiceClient I would like to catch when there's an issue with the used JWT token.

I've been reading up on the documentation but seems to be no specific error related to this.

ChatGPT suggests this setup (simplified below), but can't find any proof of it in any documentation.

catch (FaultException<OrganizationServiceFault> ex)
{
    var message = ex.Message.Contains("jwt", StringComparison.OrdinalIgnoreCase)
        ? "Request failed because of JWT exception."
        : "Request failed.";

    logger.LogError(ex, message, requestType.Name);
}

How could this be solved in a controlled and structured way?

3
  • The link you provided mentions the following exceptions as well: SecurityTokenValidationException, ExpiredSecurityTokenException, SecurityAccessDeniedException, MessageSecurityException, SecurityNegotiationException. Maybe those are relevant with the case you mention. Commented Aug 20 at 8:01
  • The description seems to be some other token, JWT is not mentioned, but I don't know, was hoping someone would. For example for ExpiredSecurityTokenException it states Exception thrown when a CardSpace security token expires.. Commented Aug 20 at 8:29
  • Only when instantiating a ServiceClient instance token issues can be expected. Normally we do not need to catch authentication errors when invoking common Dataverse requests. Commented Aug 25 at 8:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.