question

mrjdavidfg avatar image
mrjdavidfg asked

Facebook/Google LogIn using the same PlayFab Account

Hello Everybody!

I am new with PlayFab. I'm testing it for implementing it in a Unity project. I want the app to allow the user to login with Facebook and Google accounts, so a new PlayFab account is created for each new user logged in.

I implemented the Facebook and Google login with Facebook SDK and Google Sign-In Unity Plugin and I managed to do it successfully with both.

To show a bit of the code used I leave this below:

PlayFab LogIn with Facebook

var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;

LoginWithFacebookRequest request = new LoginWithFacebookRequest();
request.AccessToken = aToken.TokenString;
request.TitleId = PlayFabSettings.TitleId;
request.CreateAccount = true;

PlayFabClientAPI.LoginWithFacebook(request, OnLoginCallback, OnApiCallError);

PlayFab LogIn with Google

LoginWithGoogleAccountRequest request = new LoginWithGoogleAccountRequest();
request.ServerAuthCode = googleSignInUser.AuthCode; // GoogleSignInUser is the result of a successful google login
request.TitleId = PlayFabSettings.TitleId;
request.CreateAccount = true;

PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginCallback, OnApiCallError);

But the problem is... When I login to PlayFab in my app, once with Facebook and once again with Google, and i look the PlayFab Console, in the Players section, two different players appear for each login with each account (fb/google).

How can the app to create just one PlayFab player for every user, even if the user login with the two different accounts that have the same email linked?

I hope I have made myself understood.

I appreciate all your help you can give me. Thanks in advance.

Account ManagementAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

The key is to use the appropriate Link... API call once you have signed into the PlayFab account, in order to link the various login mechanisms to the same PlayFab account. So, if you log into Facebook first, then use the LinkGoogleAccount API call to then connect the Google account. That way, the next time the player signs in, whether they use Facebook or Google, they'll get to the same account. I'd recommend having a look at these tutorials:

https://api.playfab.com/docs/tutorials/landing-players/best-login

https://api.playfab.com/docs/tutorials/landing-players/account-linking

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dotgames2021 avatar image
dotgames2021 answered

Hi mrjdavidfg , can u please send me the script.... It is usefull to me

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

HackerTester avatar image HackerTester commented ·

@dotgames2021 hey i dont think its something too advanced refer to this video and u got the scripts in description -> https://www.youtube.com/watch?v=FIse9VOk-FE

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.