Share via

How to gracefully fail an automatic token refresh

Jeroen H 60 Reputation points
2025-01-09T09:43:43.33+00:00

Hi all,

I'm using the CallClient from @azure/communication-calling to pick up on and add functionality to incoming Teams calls for users. When creating the teams CallClient, a 'tokenRefresher' can be assigned which periodically calls the method you assign to it. The method has token refresh logic to keep the CallClient working.

With my token refresh method, it is possible that a new token cannot be generated and no token can be returned. This will cause an ugly error in the tokenRefresher itself, and I fear it may crash my application at some point. Because the tokenRefresher is called outside of my managed code, I also can't add any error handling for it.

Is there a way to gracefully fail the tokenRefresher? From what I could tell the documentation recommends to return 'undefined' when no token can be refreshed. However, this still results in a 'Uncaught (in promise) InvalidTokenError: Invalid token specified: must be a string' error which I can't handle.

I understand that there is an abortSingal parameter that I can use, but this only helps with signaling new behavior outside the tokenRefresher, while I want the tokenRefresher itself to abort without error.

Azure Communication Services
Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs


1 answer

Sort by: Most helpful
  1. Jeroen H 60 Reputation points
    2025-02-24T09:02:50.86+00:00

    Hi @Laxman Reddy Revuri ,

    Please refer to me as @Jeroen H , I'm afraid Jeroen Harpe is another user unrelated to this post.

    Thank you for your previous responses. I would pin your comment of february 20th as an answer, but unfortunately that's not possible for comments, so instead, I'll pin this as an answer.

    I might contact the Azure support channels, in which case I will update this post with an eventual answer. For now, however, I will let the issue rest, as there are no straightforward solutions available.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.