Hi @jubing long ,
Thanks for reaching out.
From your query I understand that you are looking for built in MSAL method to get access token synchronously.
MSAL doesn’t seem to have synchronous method to acquire token. MSAL provide built in methods to AquireToken asynchronously.
In other way, y ou can try to use Async/Await in a method to make asynchronous code behave in a synchronous way. The async method is executed just like any other method. That is, it runs synchronously until it hits an “await” (or throws an exception).
Or you could easily enhance your code by calling MSAL acquireTokenSilent and making it synchronous with locks to block the current thread until the response is received.
Hope this will help to address your scenario.
Thanks,
Shweta
---------------------------------------------------
Please remember to "Accept Answer" if answer helped you.