Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
Thank you for posting your question in the Microsoft Q&A forum.
From your description, it appears you’re using both delegated tokens and application (app‑only) tokens in the same solution for different purposes, and MSAL is used to acquire tokens for both authentication flows. This scenario is inherently more complex because you’re switching execution between two security contexts. You’ve already verified permission grants and admin consent, yet you’re still observing intermittent failures when switching contexts.
To help troubleshoot further, could you share the exact HTTP status code and error details (including any error, error_description, and claims challenges) returned when the calls fail? These details are essential to distinguish a permissions/consent issue from a token‑lifecycle or conditional access challenge.
For clarity: delegated and app‑only tokens carry different claims. Delegated tokens present scp (scopes), while application tokens present roles (app roles). Please log and inspect the token used for each failing request to confirm that the token type matches the endpoint’s requirement. You can safely decode the JWT at jwt.ms and verify the aud, tid, appid/azp, and the presence of scp (delegated) or roles (application), but not both simultaneously.
*The link above may reference Microsoft-related content but is not hosted on an official Microsoft domain (such as .microsoft.com). Please note that Microsoft is not responsible for the accuracy, security, or advertising on this site.
Regarding renewal behavior: MSAL caches tokens after acquisition. For delegated flows, MSAL will attempt silent acquisition and, when needed, use a refresh token to obtain a new access token without user interaction (subject to your policy constraints). In contrast, client credentials (app‑only) flows do not use refresh tokens; when an app‑only access token expires, your code must request a new token.
Because your solution uses both token types, I recommend clearly separating token caches and acquisition paths to avoid cross‑context reuse of the wrong token. In practice, that means using distinct MSAL client instances and cache partitions for delegated versus app‑only operations, and always mapping each endpoint to the required permission type before issuing the call. The MSAL articles below provide concrete details for two token type cache:
- https://learn.microsoft.com/en-us/entra/msal/dotnet/how-to/token-cache-serialization?tabs=msal#token-cache-types
- https://learn.microsoft.com/en-us/entra/identity-platform/msal-acquire-cache-tokens#acquiring-tokens-silently-from-the-cache
I hope this helps.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.