← All posts

· 6 min read

Playkids: Preserving Subscriptions During an Auth Migration

How I used legacy JWTs, token exchange, and migrated sessions to preserve Playkids user identity during a backend authentication migration.

Node.jsJWTToken ExchangeBackend MigrationApple Subscriptions

Video

Watch the video overview of this case study

The challenge: preserve identity, not just authentication

While working on Sandbox Group's Playkids App, I faced a production backend migration with a risk that went beyond unexpected logouts: existing users could lose access to subscriptions they had already paid for.

The mobile application served millions of users. Its legacy backend used JWT-based authentication, while the new backend introduced a different token strategy. The goal was to transition existing sessions without forcing users to log out or authenticate again.

The application supported two types of users:

  • Registered users, whose identity was connected to an account and login credentials.
  • Anonymous users, who could use the application without creating an account.

Both groups could have active Apple subscriptions. Registered users had a conventional account through which their identity could be recovered. Anonymous users did not necessarily have credentials to sign in again.

If the migration broke an anonymous user's identity, it could also break the relationship between that user and their subscription entitlement.

This made identity continuity a business-critical requirement, not simply an authentication concern.

Investigation: what the legacy system already knew

Before designing the solution, I investigated how the legacy backend generated tokens, identified users, and maintained sessions. Two findings revealed a practical bridge between the systems.

The legacy JWT contained the user ID

Examining the token-generation code and its payload showed that the old token contained the user ID. That meant an existing token carried information that could help recover the legacy identity during migration.

The distinction matters: reading a token payload is not the same as trusting it. In the migration flow, the backend needed to validate the legacy token before using its identity.

Session records persisted independently of the token

The old system maintained session entries using randomly generated UUIDs in its login and logout flows. Those records also contained the associated user identity.

These records provided a persistent connection between a legacy session and its user, including users without conventional credentials. The old token did not have to be discarded immediately; the token and session data could instead establish continuity with the new backend.

The compatibility gap was therefore broader than a change in token format. The new authentication strategy also needed a way to resolve the identities and state represented by existing sessions.

The solution: an exchange-token API

I proposed an exchange-token mechanism to bridge the authentication systems. Rather than requiring a fresh login, the application could exchange an existing legacy token for one accepted by the new backend.

The workflow was:

  1. The mobile application launches with an existing user session.
  2. It sends its legacy token to the exchange-token endpoint.
  3. The backend validates the legacy token and extracts the relevant user identity.
  4. The backend resolves that identity against the migrated session records.
  5. It issues a new token using the new authentication strategy.
  6. The application continues with the new token without requiring an unnecessary login.

This was a compatibility bridge, not a requirement that every existing user repeat the registration or sign-in journey.

Migrate the authentication mechanism without unnecessarily migrating the user's login experience.

The workflow above describes the implemented approach; it is not a reproduction of proprietary endpoint code or internal API contracts.

Why migrating session records mattered

The exchange-token API alone would not have solved the anonymous-user problem. The new backend also needed the legacy session information to resolve existing identities correctly.

I migrated the existing session entries into the new backend so those records could act as a bridge between the old and new authentication models.

That avoided an assumption that every user could be recovered through an email address, password, or other registered-account credential. For anonymous users, the persistent relationship between their session and identity was especially important.

The implementation relied on two connected pieces:

  • Token exchange provided a transition from the legacy authentication strategy to the new one.
  • Migrated session records provided the identity context needed to make that transition meaningful.

Understanding the legacy codebase revealed a migration path that was not obvious from the new authentication architecture alone.

Apple subscriptions and the testing constraint

Authentication was only one side of the problem. Subscription lifecycle events were managed through Apple's infrastructure and communicated to the backend through server notifications and webhooks.

In this project, we did not have a usable sandbox environment for validating the complete subscription flow. This was a limitation of our available testing setup, not a claim that Apple offers no subscription sandbox tools.

Compared with the test-mode workflows I was familiar with in Stripe integrations, our available setup made it harder to exercise the complete migration safely.

I could not assume that every real-world subscription scenario could be reproduced before making changes to a live application. Preserving the existing identity relationships therefore remained a central design requirement.

Working during an active rollout

The new mobile application had already been released to approximately 2% of users. Some existing users could potentially encounter unexpected logouts if the new backend no longer accepted their legacy sessions.

The work was not an isolated migration before launch. It required a compatible transition path while the rollout was already underway.

My priorities were to:

  • Preserve the relationship between existing users and their legacy identities.
  • Maintain compatibility with the old token strategy during the transition.
  • Exchange legacy tokens for tokens accepted by the new backend.
  • Resolve both registered and anonymous users through migrated session records.
  • Avoid unnecessary authentication interruptions that could affect subscription access.

Implementation and impact: what I can substantiate

I implemented the core solution within one day: an exchange-token API supported by migrated legacy session records.

The resulting migration path was designed to let existing sessions transition to the new authentication system without forcing unnecessary logins, including for anonymous users whose subscriptions depended on identity continuity.

The available case-study evidence does not include a complete subscription sandbox test or measured post-rollout subscription-retention results. I therefore do not claim a verified zero-loss rate, a quantified reduction in logouts, or a complete validation of every Apple subscription scenario.

What this work demonstrates is the implemented compatibility approach and the reasoning behind it: preserve the user identity and session relationships on which subscription access depends.

Key takeaways for backend migrations

  1. Map identity relationships before replacing tokens. A new token strategy does not automatically preserve the state associated with an existing session.
  2. Treat anonymous users as real identities. Their entitlements and application state may exist without a conventional account.
  3. Investigate legacy persistence. Session records can reveal a transition path that token-generation code alone does not show.
  4. Design for rollout realities. Compatibility matters even more when some users already have the new application.
  5. Be explicit about testing limits. An implemented migration path and fully verified subscription outcomes are different claims.

Final takeaway

This was not simply an endpoint implementation. It was a production migration problem involving authentication compatibility, anonymous-user identity, persistent sessions, subscription continuity, and limited testing capabilities.

By investigating the legacy JWT and session model, migrating session records, and introducing token exchange, I established a path designed to preserve existing user sessions across backend systems.

Do not migrate only the authentication mechanism. Preserve the identity relationships and application state that depend on it.