MSALPublicClientApplication.acquireTokenSilent() completionBlock not called
I've been observing random situations where MSALPublicClientApplication.acquireTokenSilent() completionBlock is not being called.
The code looks roughly following and is executed in main-thread.
let semaphore = DispatchSemaphore(value: 0)
let parameters = MSALSilentTokenParameters(scopes: ["\(clientId)/.default"], account: msalAccount)
msalApplication.acquireTokenSilent(with: parameters, completionBlock: { result,error in
// not getting called
semaphore.signal()
})
semaphore.wait() // waits for ever
Could it be the the code itself - which is effectively blocking the main thread? I.e is MsalApplication.acquireTokenSilent() dispatching something syncronously to main queue (in some certain condition), which would be then blocked by above code, which would then lead in not getting the callback via completionBlock?
Issue has been with MSAL 1.19 and lower versions for quite a while. Environment has MFA and MDM enabled.
Code seems to work in 99% time. It seems that killing the app process doesn't help. Then it suddenly starts working after few hours. It's almost like some IPC thing is stuck on (i)OS level for longer time.
Could you please provide us the MSAL logs such that i can take a deeper look? (If you haven't setup the logging yet, see here for details)
BTW, are you calling the silent call in main thread? Can you try to call the silent call in a background thread? Let me know what you find out.
Thanks so much for the response.
We'll enable MSAL logging, to be able to gather more info.
And yeah, the silent call is done in main thread. Moving the silent call is into background thread is something to consider, but I would first try to get the logs.
This issue has been automatically marked as stale because it has not had recent activity. Please provide additional information if requested. Thank you for your contributions.
No update. Closing
something was adjusted on corp Azure AAD to overcome this (didn't get further information what was done)