Hi,
We let the player log in via device. Then after a few games he can link with FB.
As explained in the tutorial (https://api.playfab.com/docs/tutorials/landing-players/facebook-unity) linking the player works nicely:
public void LinkFacebook() { Debug.Log("Link Facebook"); FB.Init(OnFacebookInitialized); } private void OnFacebookInitialized() { Debug.Log("Logging into Facebook"); // We invoke basic login procedure and pass in the callback to process the result FB.LogInWithReadPermissions(null, OnFacebookLoggedIn); } private void OnFacebookLoggedIn(ILoginResult result) { // If result has no errors, it means we have authenticated in Facebook successfully if (result == null || string.IsNullOrEmpty(result.Error)) { Debug.Log("Access Token: " + AccessToken.CurrentAccessToken.TokenString); ZPlayerPrefs.SetString(fbAccesKey, AccessToken.CurrentAccessToken.TokenString); LoginWithFacebookRequest request = new LoginWithFacebookRequest() { CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString, InfoRequestParameters = accountParams }; PlayFabClientAPI.LoginWithFacebook(request, OnLoggedIn, OnLoginError); } else { Debug.Log("Facebook Auth Failed: " + result.Error + "\n" + result.RawResult); } }
When the player logs in for a next game, we have the following Start method:
void Start() { if (HasStoredLogin()) { LoginWithEmail(ZPlayerPrefs.GetString(emailKey), ZPlayerPrefs.GetString(pwdKey)); } else if (HasFbAccesKey ()) { LoginWithFacebookRequest request = new LoginWithFacebookRequest() { AccessToken = ZPlayerPrefs.GetString(fbAccesKey), InfoRequestParameters = accountParams }; PlayFabClientAPI.LoginWithFacebook(request, OnLoggedIn, error => { OnLoginError(error); instance.LoginWithDevice(); }); } else { LoginWithDevice(); } #endif }
Although HasFbAccesKey returns true and the AccesToken (retrieved from the linking) is passed in the request, the LoginWithFacebook call returns an error and thus a LoginWithDevice is called (which isn't so bad).
But I fail to see why the LoginWithFacebook call doesn't succeed. What could be the issue?