Use FacebookID as primary identification method / Deregister deviceAuthentication.
R
Rafal Szekalski
started a topic
almost 7 years ago
Hi
I have a WebGL game made with Unity with device authentication (automatic at the game start) and optional Facebook login at the button press.
DeviceAuthentication is used to access leaderboard data if player has not logged with his Facebook profile. I don't think there is a way to acces GS data if you're not authenticated in some way, am I right? Facebook login is required to have your name and fb profile picture displayed in game. Facebook login is also required if you want to save your score to leaderboard. It's working pretty well, but trouble starts when player uses different devices to play the game. If player uses browser to play my game and then use his mobile device to play it again I get two different player profiles with the same Facebook data. That leads to situations where one player can have more than one leaderboard entry (normally, I'm just using player high score). Is there a way to merge those accounts based on FacebookID? Alternatively is there a way to deregister device before logging in with Facebook so it will be my only way of identifying a user?
There is a second question that is probably tightly connected with above one. I would also like to have an option to disconnect Facebook from my game. Player might want to hand his phone with the game to his friend so he can log to his Facebook profile and play the game. That would be easy with FacebookID as my only way of identifying user. But in case of merging device with FacebookID that might lead to some problems like taking over leaderboard scores that were posted with previous FacebookID. Is there a way to avoid those kind of problems?
As for the multiple accounts, when using FacebookConnectRequest you can alter its behaviour with the following flags:
"doNotLinkToCurrentPlayer": If there is no player already linked to the external profile, create a new player rather than linking to the currently authenticated player.
"errorOnSwitch": If the provided token is linked to another player, return an error rather than switching automatically.
"switchIfPossible": If the current player has an external profile and the provided token links to another player, allow the switch.
As for the multiple accounts, when using FacebookConnectRequest you can alter its behaviour with the following flags:
"doNotLinkToCurrentPlayer": If there is no player already linked to the external profile, create a new player rather than linking to the currently authenticated player.
"errorOnSwitch": If the provided token is linked to another player, return an error rather than switching automatically.
"switchIfPossible": If the current player has an external profile and the provided token links to another player, allow the switch.
That should help you sort that issue.
Thanks,
Oisin
R
Rafal Szekalski
said
almost 7 years ago
Thanks for quick reply, Oisin!
First tests after using what you've suggested looks very promising, no issues so far. I'm not sure why I haven't seen those flags in documentation in the first place.
M
Mighty Pirates
said
over 6 years ago
Hi,
We're using GameSparks for Unity, and we want to automatically use device authentication once GameSparks fires the available delegate, and then the user can decide to log in to facebook to migrate the player.
We were noticing that the userId returned when connecting first with device authentication is different when later connecting with facebook. Is this intended behaviour? Posting a score while authenticated by device and posting a score while authenticated by facebook creates two different entries (even if the score is the same).
So the questions are:
1) If merging has been properly done, would the same playerId be used?
2) Are we doing something wrong the in code (below)?
public class BackendManager : MonoBehaviour
{
string[] READ_PERMISSIONS = { "user_friends", "email" };
void Start()
{
FB.Init(OnFacebookInitialised);
GS.GameSparksAvailable = OnGameSparksAvailable;
}
void OnGameSparksAvailable(bool isAvailable)
{
if (isAvailable &&
!FB.IsLoggedIn)
{
new DeviceAuthenticationRequest().Send((response) =>
{
if (response.HasErrors)
{
Debug.LogError("Error connecting to gamesparks anonymously " + response.Errors.ToString());
} else
{
Debug.Log("Connected anonymously with user Id " + response.UserId);
}
});
}
}
void OnFacebookInitialised()
{
Debug.Log("Facebook Initialised. Logged in? " + FB.IsLoggedIn);
}
void OnFacebookLogin(ILoginResult result)
{
if (result.Error != null)
{
Debug.LogError("Error logging in to facebook: " + result.Error);
} else
{
new FacebookConnectRequest().SetAccessToken(AccessToken.CurrentAccessToken.TokenString).
SetDoNotLinkToCurrentPlayer(false).
SetSwitchIfPossible(true).
Send((response) =>
{
if (response.HasErrors)
{
Debug.LogError("Something failed with connecting with Facebook: " + response.Errors.ToString());
}
else
{
Debug.Log("Connected with Facebook successfully " + response.UserId);
}
});
}
}
public void OnLoginToFacebookButtonClickMsg()
{
FB.LogInWithReadPermissions(READ_PERMISSIONS, OnFacebookLogin);
}
}
Rafal Szekalski
Hi
I have a WebGL game made with Unity with device authentication (automatic at the game start) and optional Facebook login at the button press.
DeviceAuthentication is used to access leaderboard data if player has not logged with his Facebook profile. I don't think there is a way to acces GS data if you're not authenticated in some way, am I right?
Facebook login is required to have your name and fb profile picture displayed in game. Facebook login is also required if you want to save your score to leaderboard. It's working pretty well, but trouble starts when player uses different devices to play the game. If player uses browser to play my game and then use his mobile device to play it again I get two different player profiles with the same Facebook data. That leads to situations where one player can have more than one leaderboard entry (normally, I'm just using player high score). Is there a way to merge those accounts based on FacebookID? Alternatively is there a way to deregister device before logging in with Facebook so it will be my only way of identifying a user?
There is a second question that is probably tightly connected with above one. I would also like to have an option to disconnect Facebook from my game. Player might want to hand his phone with the game to his friend so he can log to his Facebook profile and play the game. That would be easy with FacebookID as my only way of identifying user. But in case of merging device with FacebookID that might lead to some problems like taking over leaderboard scores that were posted with previous FacebookID. Is there a way to avoid those kind of problems?
Hi Rafal,
SocialDisconnectRequest to disconnect Facebook.
As for the multiple accounts, when using FacebookConnectRequest you can alter its behaviour with the following flags:
"doNotLinkToCurrentPlayer": If there is no player already linked to the external profile, create a new player rather than linking to the currently authenticated player.
"errorOnSwitch": If the provided token is linked to another player, return an error rather than switching automatically.
"switchIfPossible": If the current player has an external profile and the provided token links to another player, allow the switch.
That should help you sort that issue.
Thanks,
Oisin
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Rafal,
SocialDisconnectRequest to disconnect Facebook.
As for the multiple accounts, when using FacebookConnectRequest you can alter its behaviour with the following flags:
"doNotLinkToCurrentPlayer": If there is no player already linked to the external profile, create a new player rather than linking to the currently authenticated player.
"errorOnSwitch": If the provided token is linked to another player, return an error rather than switching automatically.
"switchIfPossible": If the current player has an external profile and the provided token links to another player, allow the switch.
That should help you sort that issue.
Thanks,
Oisin
Rafal Szekalski
First tests after using what you've suggested looks very promising, no issues so far. I'm not sure why I haven't seen those flags in documentation in the first place.
Mighty Pirates
Hi,
We're using GameSparks for Unity, and we want to automatically use device authentication once GameSparks fires the available delegate, and then the user can decide to log in to facebook to migrate the player.
We were noticing that the userId returned when connecting first with device authentication is different when later connecting with facebook. Is this intended behaviour? Posting a score while authenticated by device and posting a score while authenticated by facebook creates two different entries (even if the score is the same).
So the questions are:
1) If merging has been properly done, would the same playerId be used?
2) Are we doing something wrong the in code (below)?
1 person likes this
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics