We have an iOS app which communicates with a web-service.
It uses OAuth authentication (via AppAuth) with access_token
and refresh_token
. When short access_token
expires, we need to refresh it using refresh_token
.
We are now adding a Today Extension and want to make the extension communicate with a web-service too. But there is a problem – how to handle the renewal of the access/refresh token pair?
It seems like the main app might be sleeping when Today Extension is running, so sometimes there might be a situation when we want to refresh the access_token right from Today Extension. Since that invalidates the other refresh_token
we have in the main app, it becomes very tricky to synchronize tokens back and forth.
Is there any established way to synchronize token refreshing? Or maybe we should reconsider our approach somehow?
We use Keychain to store and share tokens right now, that part works great. But refreshing and syncing of tokens is something we are having a hard time figuring out.