question

Dorofeev Ivan avatar image
Dorofeev Ivan asked

LinkGoogleAccount InvalidGoogleToken 1026

1. LoginWithGoogleAccount success!

2. Delete app and load again

3. Login with anonymous (Android Id)

4. LinkGoogleAccount:

new LinkGoogleAccountRequest
{
	ForceLink = null, 
 	ServerAuthCode = serverAuthCode
}

5. Get error: LinkedAccountAlreadyClaimed 1012

6. LinkGoogleAccount:

if i want delete old account and connect this anonymous account:

new LinkGoogleAccountRequest
{
	ForceLink = true, 
 	ServerAuthCode = serverAuthCode
}

if I want load old account:

new LinkGoogleAccountRequest
{
	ForceLink = false, 
 	ServerAuthCode = serverAuthCode
}

But in step 6 I get: InvalidGoogleToken 1026

Please help me!

All code:

void Start()
	{
		PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
			.AddOauthScope("profile")
			.RequestServerAuthCode(false)
			.Build();
		PlayGamesPlatform.InitializeInstance(config);
		PlayGamesPlatform.DebugLogEnabled = true;
		PlayGamesPlatform.Activate();
		WriteLog("\n");
	}


	public void ClickLinkWithGoogle()
	{
		LinkWithGoogle(null);
	}


	public void ClickUseThisAccount()
	{
		LinkWithGoogle(true);
		DialogWindowYesNo.SetActive(false);
	}


	public void ClickLoadOldGoogleAccount()
	{
		LinkWithGoogle(false);
		DialogWindowYesNo.SetActive(false);
	}


	public void ClickHideDialogWindow()
	{
		DialogWindowYesNo.SetActive(false);
	}


	private void LinkWithGoogle(bool? forceLink)
	{
		Social.localUser.Authenticate(success =>
		{
			if (success)
			{
				var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();


				PlayFabClientAPI.LinkGoogleAccount(new LinkGoogleAccountRequest
				{
					ForceLink = forceLink,
					ServerAuthCode = serverAuthCode
				}, result =>
				{
					LinkWithGoogleButton.GetComponent<Button>().interactable = false;
					LinkWithGoogleButton.GetComponentInChildren<Text>().text = "Already linked Google";
				}, error =>
				{
					WriteLog("\nGood error: " + error.GenerateErrorReport());
					WriteLog("\nGood error (ToString()): " + error);
					WriteLog("\nError code: " + error.Error);
					if (error.Error == PlayFabErrorCode.LinkedAccountAlreadyClaimed)
					{
						DialogWindowYesNo.SetActive(true);
					}
				});
			}
			else
			{
				WriteLog("\nFail Google Play Games login (Button)");
			}
		});
	}
Account ManagementAuthenticationandroid
10 |1200

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

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Hi @Dorofeev Ivan,

It looks like you are trying to re-use the Server Auth Code used in the call to LoginWithGoogleAccount in the whole session. It’s the same function call on our side to validate the auth code and get a token, whether it’s for login or linking operation. Therefore, attempting to re-query for a token using the same auth code is likely to result in an error. Could you try to re-authenticate the users to get a fresh auth code, and link with it? More details can be found in this thread.

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.