Is it possible to get fresh token synchronously?
From what I gathered all callbacks in the -[performActionWithFreshTokens] function are performed on the main tread/queue.
Even if I use -[performActionWithFreshTokens:additionalRefreshParameters:dispatchQueue:] that will only execute my callback/action on the specified thread. There is still logic inside the method that dispatches to the main tread/queue. It calls -[OIDAuthorizationService performTokenRequest:originalAuthorizationResponse:callback:] which dispatches its callback on the main thread.
This in turn stops me from hacking the method to become synchronous by blocking the main thread and waiting for my callback. Because if I block it the underlying logic that has dispatches on the main thread won't run. (I know blocking main thread is bad but I will live with it if it does the job)
I understand that for my problem to be solved AppAuth should not execute everything on the main thread. Currently because AppAuth is not thread safe that can not be done. Probably making it thread safe is a huge task.
Is there a way that I can currently do what I want even in a hacky way?
I found out that there was an Issue #46 about some callbacks being executed on the main thread when it is not aways wanted. However only one of the suggested methods got the change with #273.
Would something in the project break by dispatching to a custom "com.appauth.OIDAuthorizationService" queue in -[OIDAuthorizationService performTokenRequest:originalAuthorizationResponse:callback:]? Alternatively a queue could be passed as an argument as with performActionWithFreshTokens?
Really!
@petea @julienbodet can you have a look at this issue, please.
We have the same behaviour, we are setting a dispatchQueue which is not used everywhere in AppAuth SDK
Anyone looking at this?