question

andrewirving3 avatar image
andrewirving3 asked

Tutorial login function causing Unity Error

I'm getting invalid arguments error when trying to use the tutorial login. I am trying to call the login function from another script like so:

GameManager.GetComponent<PlayFabManager> ().Login (650D);

Here is the tutorial code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


using PlayFab;
using PlayFab.ClientModels;


public class PlayFabManager : MonoBehaviour {
	
	public string PlayFabId;


	// Use this for initialization
	void Start () {
		 PlayFabSettings.TitleId = "650D";
	}
	
	// Update is called once per frame
	void Update () {
		
	}


	public void Login(string titleId)
	{
		LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
		{
			TitleId = titleId,
			CreateAccount = true,
			CustomId = SystemInfo.deviceUniqueIdentifier
		};


		PlayFabClientAPI.LoginWithCustomID(request, (result) => {
			PlayFabId = result.PlayFabId;
			Debug.Log("Got PlayFabID: " + PlayFabId);


			if(result.NewlyCreated)
			{
				Debug.Log("(new account)");
			}
			else
			{
				Debug.Log("(existing account)");
			}
		},
			(error) => {
				Debug.Log("Error logging in player with custom ID:");
				Debug.Log(error.ErrorMessage);
			});
	}




}
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

·
brendan avatar image
brendan answered

Can you post the complete body of the error response? The invalid arguments response normally states specifically which parameters the issue is concerning. Can you confirm that the PlayFabSettings.TitleId is what's being passed into your Login call as the titleId string?

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.

andrewirving3 avatar image andrewirving3 commented ·

I managed to fix it. I was missing the quotation marks needed for the string:

Before

GameManager.GetComponent<PlayFabManager> ().Login (650D);

After

GameManager.GetComponent<PlayFabManager> ().Login ("650D");
0 Likes 0 ·
brendan avatar image brendan andrewirving3 commented ·

Whoop - by the time I got to the bottom I'd forgotten that line was up there, or I'd've mentioned it. :)

Glad you're unblocked - let us know if you run into any other issues.

0 Likes 0 ·

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.