Facebook Connection Failed to GameSparks Server in Unity

First of all, I am not sure this is the right place for this question. So if it is not please, forgive me.

I’m setting up the Facebook Connection to GameSparks server with FacebookConnectRequest using Facebook SDK for Unity. However, I’m getting an error response with key “accessToken” and value “NOTAUTHENTICATED”. The details of the error is “The system was unable to authenticate the token.”.

I have tried to reimport Facebook and GameSparks SDK in Unity. Change the some initialization of the Facebook and GameSpark in the code. However, I could not come up with a solution.

public void ConnectPlayerViaFacebook()
{
    ChangeCurrentText("Connecting Facebook With Server...");
    Debug.Log("Connecting Facebook With GameSparks...");// first check if FB is ready, and then login //
                                                        // if it's not ready we just init FB and use the login method as the callback for the init method //
    if (!FB.IsInitialized)
    {
        ChangeCurrentText("Initializing Facebook...");
        Debug.Log("Initializing Facebook...");
        FB.Init(ConnectGameSparksToGameSparks, null);
    }
    else
    {
        FB.ActivateApp();
        ConnectGameSparksToGameSparks();
    }
}

///<summary>
///This method is used as the delegate for FB initialization. It logs in FB
/// </summary>
private void ConnectGameSparksToGameSparks()
{
    if (FB.IsInitialized)
    {
        FB.ActivateApp();
        Debug.Log("Logging into Facebook...");
        ChangeCurrentText("Logging into Facebook...");
        var perms = new List<string>() { "public_profile", "email" };
        FB.LogInWithReadPermissions(perms, (result) =>
        {
            if (FB.IsLoggedIn)
            {
                ChangeCurrentText("Logged in, Connecting Server via Facebook...");
                new FacebookConnectRequest()
                .SetAccessToken(AccessToken.CurrentAccessToken.TokenString)
                .SetDoNotCreateNewPlayer(false)
                .SetDoNotLinkToCurrentPlayer(false)
                .SetSwitchIfPossible(false)
                .SetSyncDisplayName(true)
                .Send((fbauth_response) =>
                {
                    if (!fbauth_response.HasErrors)
                    {
                        ...
                    }
                    else
                    {
                        Debug.Log(fbauth_response.Errors.JSON.ToString());

                        ChangeCurrentText("Server Authentication with Facebook Failed!" + fbauth_response.Errors.JSON.ToString());
                    }
                });
            }
            else
            {
                Debug.LogWarning("Facebook Login Failed!" + result.Error.ToString());


                ChangeCurrentText("Facebook Login Failed!" + result.Error.ToString());
            }
        });
    }
    else
    {
        ConnectPlayerViaFacebook(); // If we are still not connected, then try to process again
    }

}

I want to remove the error response of the FacebookConnectRequest of the GameSparks request to connect succesfully to gameSparks with Facebook.

I have solved the problem. To prevent any undesirable situation about access token it needs to be manually refreshed. To do it, FB.Mobile.RefreshCurrentAccessToken needs to be used before FacebookConnectionRequest.

The explanation of that function is as follows: It may be desireable to manually refresh the current access token granted to the application by the user in order to retrieve up-to-date permissions, and extend the expiration date, if extension is possible. Use FB.Mobile.RefreshCurrentAccessToken to accomplish this. (source)

if (FB.IsLoggedIn)
        {
            FB.Mobile.RefreshCurrentAccessToken(callback =>
            {
                    ...
            });
            ChangeCurrentText("Logged in, Connecting Server via Facebook...");
            new FacebookConnectRequest()
            .SetAccessToken(AccessToken.CurrentAccessToken.TokenString)
            .SetDoNotCreateNewPlayer(false)
            .SetDoNotLinkToCurrentPlayer(false)
            .SetSwitchIfPossible(false)
            .SetSyncDisplayName(true)
            .Send((fbauth_response) =>
            {
                ...
            });
        }
        else
        {
            ...
        }