(continued… due to 403 errors)
- Login to the Task Tracker React Native app and create some Tasks
- Access the metadata file:
cd $HOME/Library/Developer/CoreSimulator/Devices/8B6.../data/Containers/Data/Application/2CC.../Documents/mongodb-realm/tasktracker-q.../server-utility/metadata
- Backup the file:
cp -v sync_metadata.realm sync_metadata.loggedin.realm
- Logout while still online (which clears the auth data from
sync_metadata.realm
) - Exit the app completely
- Backup the logged out file (just in case):
mv -v sync_metadata.realm sync_metadata.loggedout.realm
- Go offline (deactivate Wifi/Ethernet on macOS)
- Replace the file with the logged in version:
mv -v sync_metadata.loggedin.realm sync_metadata.realm
- Start the app while still offline: I am logged in as the previous logged in user.
- Go back online (re-activate Wifi/Ethernet on macOS)
- Check that there are no errors from connecting back to the MongoDB Realm Sync backend. Everything works.
The path for the Realm files can be found for example by using: console.log('* REALM PATH: ' + Realm.defaultPath);
somewhere after Realm.open(config)
. And the Realm files can be opened on the desktop using MongoDB Realm Studio.
This seems to work in principle, but obviously copying and swapping the sync_metadata.realm
file would not be feasible to do from within the app. Yet possibly re-inserting the refresh_token
and access_token
could be done programmatically while the user is logged out and offline.
I am only interested to re-login the most recently logged out user. Would this be feasible and how could I go about doing that in javascript on React Native? What side effects or problems could this cause?