question

bill-1 avatar image
bill-1 asked

Steam SDK version 1.57 with Unity, Using GetAuthTicketForWebApi instead of GetAuthSessionTicket to login to PlayFab..

Steam recently updated their SDK (on 5/1/23) and I am having some trouble reconnecting to PlayFab using GetAuthTicketForWebApi. I was wondering if anyone had any success with PlayFab authentication using Steam and the new Steam SDK. I've included the script I am having issue with, if anyone could possibly help or offer some direction I'd be forever thankful.

using System; using System.Collections; using Steamworks; using PlayFab; using PlayFab.ClientModels; using UnityEngine; using UnityEngine.Events; using TMPro; using Unity.Services.Core; public class UserAccountManager : MonoBehaviour { public static UserAccountManager Instance; public static UnityEvent OnSignInSuccess = new UnityEvent(); public static UnityEvent<string> OnSignInFailed = new UnityEvent<string>(); public static UnityEvent<string> OnCreateAccountFailed = new UnityEvent<string>(); [Header("Playfab Values")] [SerializeField] private TMP_Text messageOfDay = null; Callback<GetTicketForWebApiResponse_t> m_AuthTicketForWebApiResponseCallback; HAuthTicket m_AuthTicket; string m_SessionTicket; private void Awake() { Instance = this; } private IEnumerator Start() { var initializeTask = UnityServices.InitializeAsync(); while (!initializeTask.IsCompleted) { yield return null; // Wait until the end of the frame and then continue } if (initializeTask.IsFaulted) { Debug.LogError("Unity Services failed to initialize."); } else { Debug.Log("Unity Services initialized successfully"); // Call your function that uses AuthenticationService.Instance here } } private void Update() { SteamAPI.RunCallbacks(); } public void GetSteamTicketForPlayFab() { m_AuthTicketForWebApiResponseCallback = Callback<GetTicketForWebApiResponse_t>.Create(OnAuthCallback); m_AuthTicket = SteamUser.GetAuthTicketForWebApi("UnityAuth"); } void OnAuthCallback(GetTicketForWebApiResponse_t callback) { m_SessionTicket = Convert.ToBase64String(callback.m_rgubTicket); m_AuthTicketForWebApiResponseCallback.Dispose(); m_AuthTicketForWebApiResponseCallback = null; Debug.Log("Steam Ticket Received. Player Signed in with Session Ticket: " + m_SessionTicket); SignIntoPlayFabWithSteam(m_SessionTicket, "UnityAuth"); } private void SignIntoPlayFabWithSteam(string ticket, string identity) { Debug.Log("4. ----- UserAccountManager.SignIntoPlayFabWithSteam with ticket: " + ticket); PlayFabClientAPI.LoginWithSteam(new LoginWithSteamRequest { SteamTicket = ticket, CreateAccount = true }, response => { Debug.Log("Successful Account Login with Steam"); string steamName = SteamFriends.GetPersonaName(); GetUserAccountInfo(steamName); PlayerLogin.IsPlayerLoggedIn = true; Debug.Log("------OnSignInSuccess should invoke------"); OnSignInSuccess?.Invoke(); }, error => { Debug.Log($"Unsuccessful PlayFab Account Login with Steam \n {error.ErrorMessage}"); OnSignInFailed?.Invoke(error.ErrorMessage); }); } private void GetUserAccountInfo(string steamName) { PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest(), result => { string playFabDisplayName = result.AccountInfo.TitleInfo.DisplayName; if (playFabDisplayName != steamName) { UpdatePlayFabDisplayName(steamName); } }, error => { Debug.Log($"Error getting user account info: {error.ErrorMessage}"); }); } private void UpdatePlayFabDisplayName(string newDisplayName) { PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest { DisplayName = newDisplayName }, result => { Debug.Log($"Updated PlayFab display name to: {result.DisplayName}"); }, error => { Debug.Log($"Error updating display name: {error.ErrorMessage}"); }); } private void OnDestroy() { PlayerLogin.IsPlayerLoggedIn = false; } }

Authentication
1 comment
10 |1200

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

Neils Shi avatar image Neils Shi commented ·

Can you provide us with detailed error information so that we can do some research?

0 Likes 0 ·

0 Answers

·

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.