Custom JWT Authentication Refresh Token

When working with a third-party authentication service like Firebase or AuthO. How do you update the access token with App Services once the authentication refreshes the token? The only way to do this appears to be by calling login with the new credentials.

// Listen for token refresh and login when this happens
const jwt = await getNewTokenOnRefresh();
const credentials = Realm.Credentials.jwt(jwt);
const user = await app.logIn(credentials);

Is there another way to do this or is this the incorrect way to handle this?