Recommended pattern for acquiring tokens

ExchangeOnline444 21 Reputation points
2020-08-06T16:28:50.347+00:00

Hi Team,

We wanted to know the recommended pattern to acquire tokens while using the Client Credentials flow for a daemon application(confidential client application). Are we supposed to acquire the token silently i.e. from token cache?

As per the below MS technote, it is mentioned that you should not attempt to silently acquire a token in case of client credentials flow:
https://video2.skills-academy.com/en-us/azure/active-directory/develop/msal-acquire-cache-tokens

And in another MS document, we can see in the code snippet that acquireTokenSilently() is used to acquire tokens silently:
https://video2.skills-academy.com/en-us/azure/active-directory/develop/scenario-daemon-acquire-token?tabs=java

Please suggest.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,439 questions
0 comments No comments
{count} votes

Accepted answer
  1. 2020-08-06T18:22:08.387+00:00

    The recommendation to not atttempt to silently acquire tokens applies to public client applications. For Java you should call acquireTokenSilently, catch the MsalException in case there's not cached token and call acquireToken to retrieve and cache a token so you can keep calling acquireTokenSilently.

    ---
    Please let us know if this answer was helpful to you. If so, please remember to mark it as the answer so that others in the community with similar questions can more easily find a solution.


0 additional answers

Sort by: Most helpful

Your answer

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