Social media authentication

Hello

I have a question and I thought of asking it here. In my game I have 4 login procedures for the user, which are:
1) play as guest
2) vanilla sign up (username + password)
3) facebook
4) google

Now for the problems that I have been facing…
Problem : (a) play as guest and device ID

(a_1) When I click on play as guest it creates my account using my device ID and generates a user ID accordingly. If I link my facebook and google account with it, it can be done, but what if I logout and try to click on play as guest again? Will it log me back in as a NEW GUEST or as my PREVIOUS GUEST account?

(a_2) If it restores my PREVIOUS ACCOUNT then how can i prevent this? because the user would not want their old account to be restored if they click on play as guest, they would expect a new guest account to be made

(a_3) Supposing it creates a NEW GUEST account, if I click on continue with Facebook, will it load my PREVIOUS GUEST account which is linked/connected with facebook ?

Hi @samuelrichards95. I’ll answer each of your questions inline.

(a_1) When I click on play as guest it creates my account using my device ID and generates a user ID accordingly. If I link my facebook and google account with it, it can be done, but what if I logout and try to click on play as guest again? Will it log me back in as a NEW GUEST or as my PREVIOUS GUEST account?

This depends on what identifier you passed in as device ID when you created the “guest” account. For example if you use the Unity Engine API SystemInfo.deviceUniqueIdentifier you will always authenticate back into the same “guest” account.

NOTE: The SystemInfo.deviceUniqueIdentifier API has a weakness that if the device for the user is reset or an OS update is done this could rotate the identifier to a new value. This is done by design with Android and iOS to prevent analytics services from using it to track the end user. You should follow our best practices recommendation and cache the unique device identifier into PlayerPrefs and always try to read it from there before you fall back on the system method call.

(a_2) If it restores my PREVIOUS ACCOUNT then how can i prevent this? because the user would not want their old account to be restored if they click on play as guest, they would expect a new guest account to be made

This is very simple. You have total control on what value is used to create the device-based account in the game server so use a system timestamp with some additional bits for randomness. Even simpler with Unity Engine or our C# client sdks just use Guid.NewGuid().ToString() as the generated value for your guest account.

NOTE: Be careful with this kind of guest account mode. You’ll accumulate a huge number of user accounts which may never be used again by players. This is no problem in the game server but could indicate a problem with your game design.

(a_3) Supposing it creates a NEW GUEST account, if I click on continue with Facebook, will it load my PREVIOUS GUEST account which is linked/connected with facebook ?

If the player clicks to continue with Facebook I think you should use the LinkFacebook method on the client-side to update that user account to include this linked profile. That way when the player comes back to authenticate again (for example when a session token expires) they can just reauthenticate with Facebook into that user account.

Ultimately how you handle this case is entirely up to your game design. The server is flexible to whatever approach you want to use.

Alright, thanks. Will check this out.