question

Matt avatar image
Matt asked

GameCenter linking: signature does not match authentication request data

Hey folks,

I'm having some issues linking a Game Center account on iOS using the new API that includes signatures for security. Awhile back, when it wasn't secure, I had no problems linking. Now it's failing and I'm not quite sure why.

My linking call is pretty straight forward. The signature, key, salt, and timestamp I get seem to all be valid values.

PlayFabClientAPI.LinkGameCenterAccount( new LinkGameCenterAccountRequest()
{
	GameCenterId = Prime31.GameCenterBinding.getGamePlayerId(),
	Signature = signature,
	PublicKeyUrl = key,
	Salt = salt,
	Timestamp = timestamp,
	ForceLink = false,
},
( result ) =>
{
	m_AccountsLinked[ ( int )AccountType.Platform ] = true;
	callback?.Invoke();
},
( error ) => { ProcessLinkError( AccountType.Platform, error.Error, callback ); } );

The error I get is GameCenterAuthenticationFailed, and the message says: "Signature does not match the authentication request data".

Thanks for the help!

-Matt

5 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.

Sarah Zhang avatar image Sarah Zhang commented ·

Could you please tell us which platform are you using to develop the application, is it Unity? So we can try to test it on the correct platform.

0 Likes 0 ·
Matt avatar image Matt Sarah Zhang commented ·

Yes it's a Unity game, and I used the Game Center plugin from Prime31 to gather the signature, publicKeyUrl, salt, and timestamp. The log in xcode is where I got the error to report, stating the signature didn't match the request.

0 Likes 0 ·
Matt avatar image Matt Sarah Zhang commented ·

I just wanted to check in and see if there's any update on why this error would occur.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Matt commented ·

We lack the macOS development environments now and need to queue to use the development environment. After we test it, we will inform you of it as soon as possible.

0 Likes 0 ·
Show more comments
Sarah Zhang avatar image
Sarah Zhang answered

We try to write a sample to test PlayFab LinkGameCenterAccount API in Unity, we don’t use the paid plugin Prime31 and use an open-source Unity native plugin (https://github.com/desertkun/GameCenterAuth) instead. This API can work fine with signature validation. You can try to refer to the following code.

using UnityEngine;
using UnityEngine.SignInWithApple;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine.SocialPlatforms.GameCenter;
using AOT;
using System;
using Online;

...

   public void Start()
    {
        Open();
    }

...

 private void OnLoginWithAppleSuccess(LoginResult result)
    {
        Debug.Log("Login Success!");

        Process();
    }



    [MonoPInvokeCallback(typeof(GameCenterSignature.OnSucceeded))]
    private static void OnSucceeded(
           string PublicKeyUrl,
           ulong timestamp,
           string signature,
           string salt,
           string playerID,
           string alias,
           string bundleID)
    {
        Debug.Log("Succeeded authorization to gamecenter: \n" +
            "PublicKeyUrl=" + PublicKeyUrl + "\n" +
            "timestamp=" + timestamp + "\n" +
            "signature=" + signature + "\n" +
            "salt=" + salt + "\n" +
            "playerID=" + playerID + "\n" +
            "alias=" + alias + "\n" +
            "bundleID=" + bundleID);

        PlayFabClientAPI.LinkGameCenterAccount(new LinkGameCenterAccountRequest
        {
            GameCenterId = playerID,
            PublicKeyUrl = PublicKeyUrl,
            Salt = salt,
            Signature = signature,
            Timestamp = timestamp.ToString()

        }, OnLinkingSuccess, OnPlayFabError) ;

    }

    private static void OnLinkingSuccess(LinkGameCenterAccountResult obj)
    {
        Debug.Log("LinkGameCenter success!");
    }

    [MonoPInvokeCallback(typeof(GameCenterSignature.OnFailed))]
    private static void OnFailed(string reason)
    {
        Debug.Log("Failed to authenticate with gamecenter:" + reason);
    }

    private void OnLocalAuthenticateResult(bool success)
    {
        if (success)
        {
            Debug.Log("LocalAuthenticate success!");

            GameCenterSignature.Generate(OnSucceeded, OnFailed);
        }
        else
        {
            Debug.Log("LocalAuthentificate failed.");
        }
    }

    public void Process()
    {
        if (Social.localUser.authenticated)
        {
            GameCenterSignature.Generate(OnSucceeded, OnFailed);
        }
        else
        {
            Social.localUser.Authenticate(OnLocalAuthenticateResult);
        }
    }

...


2 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.

Tarm avatar image Tarm commented ·

I'm using this example and am still receiving the "Signature does not match the authentication request data" error when making the PlayFab link request. As in the example above, when logged into GameCenter it logs my public key url, timestamp, signature, salt and playerID. All values are populated with data.

Has anyone come across this issue? Perhaps I'm missing a PlayFab/Game Center setup step?

0 Likes 0 ·
SniperED007 avatar image SniperED007 Tarm commented ·

Im having the same issue.

0 Likes 0 ·
Matt avatar image
Matt answered

I swapped to use that plugin and it seems to be working. I'm not quite sure what the problem was exactly (I really don't think the P31 plugin was in error, those are generally high quality plugins) but it's working now. Thank you!

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.