The Shared Accounts feature is a powerful example of the flexibility of brainCloud’s authentication architecture. brainCloud already provides a myriad of authentication options: anonymous, e-mail address, Facebook id, Google Id, GameCenter, Twitter, etc. brainCloud can even authenticate users with external directories via our External Authentication feature. Shared Accounts takes this one step further, allowing you to create a single, shared account system for your users to access all (or select) company apps. You will then have a single repository of your users, regardless of the specific app they are using. This is useful to offer common, shared features across all apps – like shared premium currencies, meta-level leaderboards and achievements, etc. – really anything you want. For more information, please refer to our documentation -- Shared Account.

Set Parent App

  • To get started, from portal Team | Manage | Apps page, select or create a new app as parent app, then go to page Design | Authentication | Shared Accounts.
  • Check the [ Can be a Parent] checkbox, enter a name for identifier of this parent app, click Save.

Set Child App

  • Select an exist app or create an app as the child app from portal Team | Manage | Apps page, then go to Design | Authentication | Shared Accounts page of this app.
  • Check the [ Is a Child of] checkbox, select a parent app from drop-down menu, click Save.

Authenticating Users

  • Switch back to parent app and go to Design | Cloud Code | API Explorer page, using API Explore authenticate service to authenticate a user in parent app.
  • Select Identity Service and SwitchToChildProfile() api, put the child appId to the correspondent parameter and click Run.
  • Check the result of this api call
  • Switch back to the child app and go to Monitoring | User Monitoring | User Summary page to check this new created user on child app.

Call APIs

  • Click the [Login As User] button under avatar pic that will redirect you to Design | Cloud Code | API Explorer page, now, you are ready to go with using API Explore all API calls which behave the same way as they do for any other brainCloud app.
  • Check this current user's Virtual Currency on Monitoring | User Monitoring | Virtual Currency page, you will find the corresponding user's currencies in parent app.
  • Go back to Design | Cloud Code | API Explorer page, check current user state by calling ReadUserState() for the later comparison after switching to parent user.
  • Retain on the same page, call SwitchToParentProfile() API of Identity service, then call ReadUserState() again to compare the difference of the result at this point. As you can see, now the we are on the parent app! So whatever you do here just as same as you do on parent app.
  • Calling GetChildProfiles() API of Identity service to show you the list of child profiles that related to this parent user.
  • Test to increase user statistics by calling IncrementUserStats() API, putting statistics name/value pair as an parameter, see the returned result. This statistics is existed in parent app.
  • Calling SwitchToChildProfile() API of Identity service switch back to currently level user any time.
  • Call GetCurrency() API of Product service to check current currency balances of this child user and related parent user. (put null for currency type).
  • With this child current user, you can call parent scripts by calling RunParentScript() API of ScriptService Service, this client callable script will be executed as the corresponding parent user.

Note: that brainCloud will automatically adjust the server context to make the appropriate parent profile (as identified by the <app_level> current before running the script), and return it to prior app level when the script is complete.

There are other few more API calls can be called directly from child app to parent app level without calling SwitchToParentProfile():

  • AwardParentCurrency() – allows you to increment the currency balance of the specified parent-level currency
  • ConsumeParentCurrency() – allows you to decrement the balance of the specified parent-level currency
  • GetParentCurrency() – retrieves the current balance of the specified parent-level currency (note: also returned in Authentication and Player State )
  • ResetParentCurrency() – resets all currency balances at the specified parent-level (mostly useful for testing / debugging)


Did this answer your question?