Viewer (User) Configuration
Pass the current user's session data so the platform can personalize the experience and enforce access rules correctly.
MindtrainingPlatform.init('mindtraining', {
viewer: {
userId: 'user-123', // your internal user ID (string or null)
loggedIn: true, // whether the user is authenticated
subscribed: true, // whether the user has an active subscription
},
})Pass
loggedIn: falseand omituserIdfor anonymous / unauthenticated sessions.
Updating the user session
If the user's session changes after initializing the platform (for example, they log in or out without reloading the page), call updateConfig() with the updated user data. The platform updates the content automatically and keeps the current page. You do not need to call init() again.
Publisher authentication
If your integration requires publisher authentication, pass publisherToken with the matching viewer.userId. Mindtraining will confirm whether this is required for your site. The platform handles authentication automatically. When your token changes, send it with updateConfig({ publisherToken: freshToken }); use publisherToken: null to remove it. When switching accounts, send the new user ID and token together.
MindtrainingPlatform.init('rootGames', {
viewer: { userId: externalUserId, loggedIn: true },
publisherToken: currentPublisherToken,
})In required mode, the SDK calls the existing ui.actions.openLogin callback when a protected operation needs a missing credential or the exchange rejects it. Temporary service failures and background page-close saves do not prompt for login.
On a site that requires authentication, games that allow guest play save progress using a separate browser identity for that Site and domain. To play as a guest, omit the publisher credential and the registered viewer ID, and leave viewer.loggedIn false. Guest progress stays with that browser and is separate from registered progress.
When a guest signs in through init() or updateConfig(), pass the account ID and publisher token together. In required mode, the SDK links the browser’s guest progress to the verified account for the same Site and domain. If the account already has independent progress, both histories stay separate.