Here are the steps to reproduce:
- Have an app that uses the Iterable SDK and have it set up to use the JWT token
- Have a backend service that sends the app the JWT token to use in the Iterabel SDK (this service must require a valid authentication header from the app after a user has logged in)
- Log into the app so it can set an initial Iterable JWT token to the SDK
- Close the app and wait for both the Iterable JWT token and app auth token to expire
- Send push notification
- Click push notification on the device
- App opens
- App tries to refresh it's authentication token and at the same time the Iterable SDK tries to get new JWT token but since the auth token is expired it can’t get one yet
- Iterable tries to send the
api/events/trackPushOpen event but gets 401 since the old JWT token is expired
- The app auth token is refreshed and we set the user id
IterableApi.getInstance().userId = userId which triggers the Iterable SDK to try to get a new JWT token by calling onAuthTokenRequested
- The Iterable SDK gets a new JWT token and calls
api/inApp/getMessages and api/users/registerDeviceToken which succeed
- The Iterable SDK does not try to send
api/events/trackPushOpen again
It would be ideal if a request fails due to an expired JWT it should be added to a queue and once a new JWT token is set it should try to resend the failed requests in the queue.