Switching sandboxes properly for Store operations

Switching sandboxes on PC can be done a variety of ways. Using Xblpcsandbox.exe is recommended as it forces sign-out for any accounts signed into any Xbox services-enabled apps when a sandbox change occurs.

For Xbox services operations, it suffices to sign-in with an account that is provisioned to the newly switched sandbox, which is similar to signing in with different accounts in retail. Once signed in, the XUser context will understand the current sandbox.

Store operations will require an Xbox User signed into an Xbox services-enabled app to scope browsing and purchasing of products to a sandbox. Simply signing in with an account in the Microsoft Store app will default the sandbox scope to retail (or previous sandbox if one was set).

Important

Therefore it is important to sign-in to Xbox services first after switching sandboxes:

  1. From GDK command prompt: xblpcsandbox <sandbox id>
  2. Sign in on the Xbox App with account provisioned for sandbox
  3. Sign in on the Microsoft Store app with the same account

The store account can also be a different account from the Xbox account. See Handling mismatched store account scenarios on PC for more information.

This should be done in all transitions involving sandboxes:

  • from retail to sandbox
  • from one sandbox to another sandbox
  • from sandbox to retail

The most common problem with failing to do this properly is if the store account is not signed in after Xbox services sign-in, resulting in all store operations returning improper results.

Note

When testing commerce in development sandboxes, make sure that all purchases on a single test account are done in the same sandbox. Switching a test account to another sandbox and purchasing additional items will result in unexpected query results for the account in both sandboxes. This is due to the fact that the licenses and information of a purchase are tied to the first sandbox the item was purchased in for a single account.

Xbox App optimization

The Xbox App has an indicator at the top that informs what sandbox is being used:

Xbox App sandbox indicator

This will show up when the Xbox App is signed-in with an account that can be used in the sandbox switched to using xblpcsandbox (or other tool).

Using the Xbox App has the added benefit of having the app automatically attempt to reconcile the store account, meaning that if you stay within the Xbox App, catalog, purchase operations and ownership should be with respect to the same account and in the sandbox.

In-game store operations (using XStore API)

The XStoreContext that the game will obtain will be that of the store account, whether that is explicitly signed in on the Microsoft Store app or done as part of Xbox App sign-in. The best indicator of what account XStore API will use is the account that is used by the Xbox App for its store operations.

See also

Xbox Live PC Sandbox Switcher

Xbox services Sandboxes overview

Troubleshooting Sign-in Errors

Enabling XStore development and testing