Skip to main content
All CollectionsError Messages
Why I am getting a 40206 error during anonymous authentication?
Why I am getting a 40206 error during anonymous authentication?

Error messages "Credentials missing for Profile Id" and "Invalid credential for existing profile."

Paul Winterhalder avatar
Written by Paul Winterhalder
Updated over a week ago

brainCloud client apps save an anonymousId (device id) and a profileId to the local device’s storage. These pieces of data are used together by the system when attempting to reconnect the app to the user’s account.

The profileId is as you’d expect – it identifies the user’s profile. The anonymousId identifies the user’s device. brainCloud keeps track of which profile a device last connected to server-side. If the anonymousId and the profileId both point to the same profile (and that profile exists), then the authentication is deemed successful, and the user is allowed to log in.

If you are getting this error, it means that either:

  • the profile (user account) no longer exists - most likely it was a test account deleted using the portal. brainCloud returns 40206, "Credentials missing for Profile Id".

  • The anonymousId is null, but the profileId is valid (the account exists). brainCloud returns 40206, "Invalid credential for existing profile."

In either case, the user's anonymous access to this profile is now lost. The profile, even if it still exists, cannot be connected to via this anonymous id. Note that if the profile still exists it would still be accessible via other authentication types (identities) associated with the profile.

The recommended behavior is to catch the 40206 error (note, do not trigger on the messages directly - that is dangerous, as messages change), and respond by resetting the stored profileId and anonymousId on the device.

You can reset the profileId via the ResetStoredProfileId() and ResetStoredAnonymousId() methods on the BrainCloudWrapper class.

It is up to the developer as to whether they would like to display a message to the user when this occures. For example, something like “User account not found – creating new account.” or "Account connection lost - relogin to account." It is up to you as to whether that messaging makes sense for your app.

Your feedback is important to us. Please rate this response below. Thanks! 

Did this answer your question?