question

ajon542 avatar image
ajon542 asked

Login with Facebook on iOS is creating a different playfab account

Hi,

I've been seeing some weird behavior around login with facebook on iOS. There seem to be some related problems from a while back that suggest this shouldn't be possible:

https://community.playfab.com/questions/10846/bug-two-accounts-linked-with-the-same-facebook.html

I've logged in with Facebook to Playfab in the Unity editor as well as on Android and I get the same Playfab acccout:

https://developer.playfab.com/en-US/5E004/players/1BB7E62D14EE9380/overview

When I log in with Facebook to Playfab on iOS, I'm getting a new account created instead of being logged into the same account from Unity Editor/Android. I've ensured the Facebook app is installed on the device - I even tried uninstalling/reinstalling and logging in to the Facebook app again to confirm I am actually signed into the correct Facebook account. Here is the new Playfab account created:

https://developer.playfab.com/en-US/5E004/players/97E808C9B1F5D522/overview

I feel like I tested this a while back and it was working correctly, but now I'm running out of ideas on where to look next.

Here is my code just slightly altered from the example code to add an initial custom id:

https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/facebook-unity

using System;
using Facebook.Unity;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
using UnityEngine.UI;

public class PlayfabFacebookAuthExample : MonoBehaviour
{
    public Button _loginWithFacebook;

    public void Start()
    {
        SetMessage("Initializing Facebook...");
        FB.Init(OnFacebookInitialized);

        _loginWithFacebook.onClick.AddListener(LoginWithFacebook);

        LoginWithCustomId();
    }

    private void LoginWithCustomId()
    {
        PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest
        {
            CreateAccount = true,
            CustomId = Guid.NewGuid().ToString()
        }, result => SetMessage("PlayFab Custom Login Complete. Session ticket: " + result.ToJson()),
            error => SetMessage("PlayFab Custom Login Failed: " + error.GenerateErrorReport(), true));
    }

    private void LoginWithFacebook()
    {
        PlayFabClientAPI.LoginWithFacebook(
            new LoginWithFacebookRequest
            {
                CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString
            },
            result => SetMessage("PlayFab Facebook Login Complete. Session ticket: " + result.ToJson()),
            error => SetMessage("PlayFab Facebook Login Failed: " + error.GenerateErrorReport(), true));
    }

    private void OnFacebookInitialized()
    {
        SetMessage("Logging into Facebook...");

        if (FB.IsLoggedIn)
            FB.LogOut();

        FB.LogInWithReadPermissions(null, OnFacebookLoggedIn);
    }

    private void OnFacebookLoggedIn(ILoginResult result)
    {
        if (result == null || string.IsNullOrEmpty(result.Error))
        {
            SetMessage("Facebook Auth Complete! Access Token: " + AccessToken.CurrentAccessToken.TokenString);
        }
        else
        {
            SetMessage("Facebook Auth Failed: " + result.Error + "\n" + result.RawResult, true);
        }
    }

    public void SetMessage(string message, bool error = false)
    {
        if (error)
            Debug.LogError(message);
        else
            Debug.Log(message);
    }
}
Account Management
10 |1200

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

JayZuo avatar image
JayZuo answered

PlayFab identifys Facebook users by their user IDs. Different IDs will result in different account. From the responses you've shared, this player has different user IDs. I'm not sure what happened here. But the app-scoped user ID should be same no matter where you got it. This is because app-scoped user IDs will be different for different Facebook Apps. But in your scenario, both the Android and iOS app should be under the same Facebook App using the same App ID. They are simply different platforms.

I'd suggest you check your Facebook App settings and do more test to see if other Facebook users have the same issue.

10 |1200

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

Seth Du avatar image
Seth Du answered

According to your code, in start() function, you have added a listener to a click, which will call LoginWithFacebook API, while you also add LoginWithCustomID API call below.

Because PlayFab API calls in Unity SDK is asynchronous, your actual behavior is to create 2 accounts or log into two separate accounts. Since the login identity will be overwritten by the latest login, the player will continue with Facebook account.

If you want to log into an existing account, you may remove the LoginWithCustomID API call in line 19, otherwise, you may implement it as a onclick listen like what you do for Facebook login and let the player choose.

4 comments
10 |1200

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

ajon542 avatar image ajon542 commented ·

It looks like a single Facebook account is linked to multiple Playfab accounts though.

0 Likes 0 ·
ajon542 avatar image ajon542 commented ·

If you scroll down to the bottom of the accounts I posted, it looks like the same Facebook account is linked to both of them which shouldn't be possible. I expected to be able to log in to the same account when using Facebook login, but instead it looks like an entirely new account was created.

0 Likes 0 ·
ajon542 avatar image ajon542 commented ·

Logging in with a custom id is the intended behaviour so we can call Playfab APIs without having to bother the player with logging in. They can choose to login with Facebook at a later date. Once they log in with Facebook on multiple devices I would have expected it to log them in to one account and not create multiple accounts linked to Facebook.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ ajon542 commented ·

I don't see any LinkFacebookAccount API called in your code. A Facebook account can only link to one PlayFab account, when linking to a new account, error messages will be returned in the callback unless ForceLink is set true in the request of LinkFacebookAccount API.

0 Likes 0 ·
ajon542 avatar image
ajon542 answered

The same Facebook account is linked to both of these accounts. I understand that it is not supposed to be possible but somehow it appears to have occurred.

https://developer.playfab.com/en-US/5E004/players/1BB7E62D14EE9380/overview

https://developer.playfab.com/en-US/5E004/players/97E808C9B1F5D522/overview


facebook-link.png (10.3 KiB)
3 comments
10 |1200

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

Seth Du avatar image Seth Du ♦ commented ·

Would you please try to call GetAccountInfo for each player and compare the login identity within?

Creating different accounts via Facebook was reported in the forum and it was caused by Facebook Limited login on iOS.

0 Likes 0 ·
ajon542 avatar image ajon542 Seth Du ♦ commented ·

Ok, I posted the GetAccountInfo responses below. The FacebookId is different but I'm guessing this is an app scoped id and Playfab should know how to deal with this under the hood. Since the app is on both Android and iOS I would expect the app scoped ids to be different.

I read a little about this limited login with Facebook in the post here: https://community.playfab.com/questions/52252/unity-facebook-limited-login.html

Toward the end of the post it says that if you use the different login methods (classic vs limited) on iOS you will get two accounts. For example, if a user who previously logged in with the classic method now goes to log in with the limited login method.

However, I haven't implemented the limited login method at any time. I've always used the classic login method with Facebook. I'm not sure if this new method is required.

I would expect for a user who created an account with the classic login method on Android to be able to login with the classic login method on iOS and be able to log the user into an existing account rather than creating a new account. Is this not possible any more?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ ajon542 commented ·

Due to the latest policy of iOS, it seems to be impossible. However, PlayFab is able to link multiple login identities to the same account. For the solution on iOS, you may refer to this thread: Unity SDK. Facebook login: Playfab creates different accounts instead of using already created - Playfab Community

0 Likes 0 ·
ajon542 avatar image
ajon542 answered

To be clear, I already had a Facebook account linked to player id 1BB7E62D14EE9380. Upon pressing the login with Facebook button, on iOS, it created a completely separate Playfab account i.e. 97E808C9B1F5D522. It did not log me in to the existing account that was already linked with Facebook.

10 |1200

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

ajon542 avatar image
ajon542 answered
{
    "code": 200,
    "status": "OK",
    "data": {
        "UserInfo": {
            "PlayFabId": "1BB7E62D14EE9380",
            "Created": "2021-08-12T18:29:40.187Z",
            "TitleInfo": {
                "Origination": "Facebook",
                "Created": "2021-08-12T18:29:40.187Z",
                "LastLogin": "2021-08-12T18:38:51.1Z",
                "FirstLogin": "2021-08-12T18:29:40.187Z",
                "isBanned": false,
                "TitlePlayerAccount": {
                    "Id": "3AF1C69C4637A5AA",
                    "Type": "title_player_account",
                    "TypeString": "title_player_account"
                }
            },
            "PrivateInfo": {},
            "FacebookInfo": {
                "FacebookId": "10216682801647617",
                "FullName": "Andrew Jones"
            }
        }
    }
}

10 |1200

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

ajon542 avatar image
ajon542 answered
{
    "code": 200,
    "status": "OK",
    "data": {
        "UserInfo": {
            "PlayFabId": "97E808C9B1F5D522",
            "Created": "2021-08-12T18:48:43.243Z",
            "TitleInfo": {
                "Origination": "Facebook",
                "Created": "2021-08-12T18:48:43.243Z",
                "LastLogin": "2021-08-12T18:54:30.381Z",
                "FirstLogin": "2021-08-12T18:48:43.243Z",
                "isBanned": false,
                "TitlePlayerAccount": {
                    "Id": "D4DC235037706ECF",
                    "Type": "title_player_account",
                    "TypeString": "title_player_account"
                }
            },
            "PrivateInfo": {},
            "FacebookInfo": {
                "FacebookId": "304567568004056",
                "FullName": "Andrew Jones"
            }
        }
    }
}

10 |1200

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

ajon542 avatar image
ajon542 answered

It would seem that we cannot use Facebook login for cross platform login until this issue is resolved.

10 |1200

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

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.