Authentication
This section describes the key methods for implementing basic authentication in your app. These methods are all you'll need if you:
- Just want to use anonymous authentication for all users
- Want to use a single authentication type (which is required) for all users – i.e. like forced Facebook or GameCenter
- Want to get authentication going quickly during development, and will flesh out more of the authentication details later
Consult the advanced (Identity) section if/when you want to get even more flexible with authentication (giving users more flexibility to choose their preferred authentication method, merging of profiles, etc.) When implementing brainCloud authentication, there are some key things to keep in mind:
brainCloud uses an anonymous installation ID (commonly referred to as the anonymous ID) to identify individual devices. This ID must be generated for first use, and saved by the client application. brainCloud provides a convenient method for generating the ID – or the developer can generate it themselves. brainCloud also requires the client to keep track of the most recent profile ID. This, together with the anonymous ID, provides additional security and allows brainCloud to better understand user intent during logins/reconnections. If the user has never connected before the profile ID should be null.
The optional BrainCloudWrapper class will automatically persist your anonymousId and profileId as required. We highly recommend that you use it!
If you are using the API Explorer, the list of valid Platform IDs can be found here.
Handy tip: To log a user out of brainCloud, use the Logout method in Player State. Note that you don't absolutely need to log users out – their sessions will timeout on the server automatically anyway.
By default, the timeout length for authenticated users is 20 minutes. This timeout length can be lowered on the brainCloud Dashboard. [Core App Info | Advance Settings > Session Timeout]
You must authenticate and ensure it succeeds before attempting to call any other APIs that require authentication! Calling other APIs before authenticate successfully returns can cause the authenticate operation to fail.