-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async request in willSend Request #834
Comments
You would need to create a blocking version of |
@cltnschlosser thanks for the response, however I'm not entirely sure about creating a blocking version. Are you referring to something like async await? |
I don't actually know that it's a good idea in this case without some more information, but this is what you would have to do inorder to get that to compile. You would need to do something like: https://stackoverflow.com/questions/47041491/swift-wait-for-closure-thread-to-finish You will need to make a temporary result var that ends up containing the idToken and then updating the request after the semaphore wait. Given the information I have this seems like the best approach, but waiting for an asynchronous function here isn't great. Is there no synchronous method for getting a (cached, maybe) idToken? |
Supporting this sort of configuration as an async request is something we're planning on, since auth tokens are generally stored in the keychain. However, I made a gist that shows an example of a way to take an async API and turn it into a sync one so you can use it with the delegate method in question: https://gist.github.com/designatednerd/93405c0751b0c62c3c575d687a409d45 - just make sure you don't call that on the main thread since it blocks. I would also double check whether it's worth forcing refresh of the token on every single request you make - it seems like that shouldn't be necessary and you might be able to get a token you can store in-memory and then check if it's expired before forcing a refresh. |
@designatednerd and @cltnschlosser thanks for this! I will take a look. |
Hello I'm using firebase authentication and in order to get current user's token is I need to call an async function.
Could anyone shed a light on how I should do this?TIA
The text was updated successfully, but these errors were encountered: