question

Mark Whitfield avatar image
Mark Whitfield asked

Steam authentication docs out of date?

So I'm following the docs here so that users will be login to playfab using their Steam:

https://learn.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/steam-unity

However having a compile error with calling SteamUser.GetAuthSessionTicket:

6706-first.jpg

r/Unity3D - Playfab and Steam integration with Unity issue I directly copied that from the playfab docs, and furthermore if you hover the method it says SteamNetworkingIdentity is optional, so not sure why it expects 4 arguments?

6707-first2.jpg So I can't figure out why it wont accept the 3 arguments provided just like in the playfab docs?

Any advice appreciated. Thanks.

Authentication
first.jpg (162.2 KiB)
first2.jpg (278.4 KiB)
10 |1200

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

Greg Quinn avatar image
Greg Quinn answered

This code works for me, what version of Steamworks are you using?

 public static string GetSteamAuthTicket()
     {
         byte[] ticketBlob = new byte[1024];
         uint ticketSize;
    
         // Retrieve ticket; hTicket should be a field in the class so you can use it to cancel the ticket later
         // When you pass an object, the object can be modified by the callee. This function modifies the byte array you've passed to it.
         HAuthTicket hTicket = SteamUser.GetAuthSessionTicket(ticketBlob, ticketBlob.Length, out ticketSize);
    
         // Resize the buffer to actual length
         Array.Resize(ref ticketBlob, (int)ticketSize);
    
         // Convert bytes to string
         StringBuilder sb = new StringBuilder();
         foreach (byte b in ticketBlob)
         {
             sb.AppendFormat("{0:x2}", b);
         }
    
         return sb.ToString();
     }
3 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.

Mark Whitfield avatar image Mark Whitfield commented ·

I'm using the latest of this c# wrapper:

https://github.com/rlabrecque/Steamworks.NET/releases

its on v 1.57

what version are you using?

0 Likes 0 ·
Mark Whitfield avatar image Mark Whitfield Mark Whitfield commented ·

also i use the .unitypackage so can just install the package direct into unity if that matters

0 Likes 0 ·
Mark Whitfield avatar image Mark Whitfield commented ·

https://partner.steamgames.com/downloads/list

ok seems in v1.56 they made that argument mandatory, so that explains it since I'm on 1.57.

i downgraded versions and no longer get the compile error.

if i wanted to stay on 1.57 though, would it be acceptable to just send it an black SteamNetworking identity? Like this:

SteamNetworkingIdentity sn = new SteamNetworkingIdentity();

      HAuthTicket hTicket = SteamUser.GetAuthSessionTicket(ticketBlob, ticketBlob.Length, out ticketSize, ref sn);
0 Likes 0 ·
Neils Shi avatar image
Neils Shi answered

The Steamworks SDK adds a new parameter to the GetAuthSessionTicket method called “pIdentityRemote”, As ISteamUser Interface (Steamworks Documentation) (steamgames.com) mentions that “The identity of the remote system that will authenticate the ticket. If it is peer-to-peer then the user steam ID. If it is a service, a string identifier of that service if one if provided.” And our API LoginWithSteam has added a new field called "TicketIsServiceSpecific" which can be enabled to inform steam that the identity string should be validated along with the Steam ticket. As Authentication - Login With Steam - REST API (PlayFab Client) | Microsoft Learn mentions that this field "TicketIsServiceSpecific" expects a true value if the authentication ticket was generated using ISteamUser::GetAuthTicketForWebAPI() and you need to pass our service's identity string, our identity string is "AzurePlayFab". If the authentication ticket was generated using ISteamUser::GetAuthSessionTicket(), then you need to set "TicketIsServiceSpecific" to false, and it expects the ticket without an identity, just as before.

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.