Sign In Register

How can we help you today?

Start a new topic

Steam Connect Request

I am attempting to use SteamConnectRequest to link players with Steam accounts. I've double checked the Integration page to make sure I'm using the correct Steam App ID and Steam API Key.

I use Steamworks' GetAuthSessionTicket to receive a ticket (which I know returns a valid ticket since it works for Steam's BeginAuthSession). After converting the response to a hex encoded string, I end up with a string that is similar to the session ticket string in the Example Request on the SteamConnectRequest page (http://bit.ly/1OLQg3B).

However, after creating the SteamConnectRequest and setting it up with the newly created hex encoded ticket, it always returns with the NOTAUTHENTICATED error.


Is there anything I could be missing in this process that would guarantee this never works correctly, or any places to look? Here is the code I am using, if more information is needed I will be happy to oblige, thanks!


// GetAuthSessionTicket

byte[] ticket = new byte[1024];

uint length = 0;

HAuthTicket authTicket = SteamUser.GetAuthSessionTicket(ticket, 1024, out length);


// GetAuthSessionTicket Callback

if(SteamUser.BeginAuthSession(ticket, (int)length, SteamUser.GetSteamID() == EBeginAuthSessionResult.k_EBeginAuthSessionResultOK)

{

   string hexEncodedTicket = "";

   for (int i = 0; i < length; i++)

        hexEncodedTicket += String.Format("{0:X}", ticket[i]);


   new GameSparks.Api.Requests.SteamConnectRequest()

          .SetDoNotLinkToCurrentPlayer(false)

          .SetSessionTicket(hexTicket)

          .Send((response) =>

          {

              if (!response.HasErrors)

              {

                  Debug.Log("Authenticated);

              }

              else

              {

                  Debug.Log("NOTAUTHENTICATED");

              }

          });

}


Hi Hive Mind,


Are you sure you're getting a valid token ? The NOTAUTHENTICATED error means we were unable to authenticate the sessionTicket. Have you managed to make a successful authentication in your game with Steam yet ?


Thanks,

Liam

It's definitely a valid ticket from Steam because as soon as I receive it from steam, I call BeginAuthSession and send the ticket. I only create and send the SteamConnectRequest if BeginAuthSession returns k_EBeginAuthSessionResultOK. And when I catch the callback for BeginAuthSession, which gives me a ValidateAuthTicketResponse_t, the SteamID that contains is right.

The conversion I'm doing (the for loop) seems to be right, because it begins with the same characters (14000...) as the example on the SteamConnectRequest page. So I'm pretty sure I'm sending the right information.


By NOTAUTHENTICATED, do you mean that you were unable to verify with Steam that the ticket was valid, or that no account exists connected to that SteamID?

It could be that I'm misunderstanding how SteamConnectRequest works. The way I read it was, I can call this function in two ways. One way is obviously to see if a Gamesparks account is tied to a Steam ID, and if so sign into that account. The other is that when signing into an already existing Gamesparks account and sending the session ticket from Steam, if that Steam ID isn't already linked with a Gamesparks account or that Gamesparks account isn't linked with a Steam ID, it will make that link for future use. Am I wrong on the second option? And if so is there a way to do something like this?


Thanks,

James

Hi James, 


I think you have a small bug with the way you obtain the hex ticket. If ticket[i] holds a number that is smaller than 16, your logic will append only one character instead of padding it with 0.

For example, if ticket[0] == 0, you should append "00", not just "0".

You could try something like: String.Format("{0:X2}", ticket[i]).


Let me know how that works for you.


Thanks,

Alex


Ah, should have looked into that function a bit further. That was definitely part of the problem, it's converting properly now. I still get the NOTAUTHENTICATED error, however.


James

Hi James,


Do you have any other instances of the game set up on Steam ? A demo version alongside the full one perhaps ? It might be possible that you're getting the token from the wrong instance and trying to use that to authenticate with the one you have configured in GameSparks, which could in turn lead to this error, can you double check on Steam that you are using the correct Steam App ID and Steam API Key.


Thanks,

Liam

We do not, we have one game with no demo. I just checked the App ID again and it is correct, though it is entirely possible I am using the wrong key for the Steam API Key. The key I am using is labeled is the Web API Publisher Key in Steam's tools and is 32 characters long. It has been copied over properly but if I am meant to use a different key entirely than that could very well be the issue.


James

Hi James,


Thanks for the update, we'll keep looking into this for you in the meantime. It does sound like a possible issue with the api key you're using, can you also check that the app Id and secret on the client side match your set up in the steam integration tab on the portal ?


Regards,

Liam

My Steam App ID is correct, however my Web API key is not used by the client at all.


James

Hi James,


If possible can you go through the process of getting your appID and key from Steam again from the start ? Can you detail the steps you are following while you are doing this, hopefully then we 'll spot the issue. Also when you have done this can you generate a token for a user and test it with a SteamConnectRequest in the Test Harness ?


Thanks,

Liam

Absolutely!

To get the App ID I simply signed into partner.steamgames.com. The App ID is right there next to the name of the App, and this ID is definitely correct as Steam recognizes anytime I am running our build.

To get the API key, starting at the home page that signing in takes me to, I go to Users & Permissions > Manage Groups. On this page we have one group for our game which I opened. And on the right of this last page is an option to Create Web API key that I copied and pasted to Steam Integration.


I tried generating a token and copying and pasting it into the Test Harness, that also gave me NOTAUTHENTICATED.


James

Hi James, 


I was looking at your latest SteamConnectRequests. It seems like all the ones from 1st and 2nd June contain a token that was incorrectly formatted (without the fix that you put in on 31May), so it looks like you are no longer submitting correct tokens.


Also, I tried using one token that was correctly formatted and I got back this error: { "error" : { "errorcode" : 100 , "errordesc" : "User is offline"}} . When you are doing these authentications, is your steam user online? Can we do a test when you are actually logged in with this user and I try to authenticate to see if that works?


Thanks, 

Alex


To anyone reading this in the future, it was a combination of two issues. One was what Alex mentioned, the improper formatting. This is what you want:


string hexEncodedTicket = "";

   for (int i = 0; i < length; i++)

        hexEncodedTicket += String.Format("{0:X2}", ticket[i]);


The second is that BeginAuthSession essentially uses the ticket up, making it invalid for any future use. So you can't call that immediately before trying to use to connect with GameSparks, it'll never work.


Thanks to everyone who helped figure this out, you guys are awesome!

James


2 people like this

Hi,


I'm also having this issue (8 months later) and I'm at a loss. My app ID and webapi seem to be set up correctly, I can get the ticket from steam but if I try to login to GameSparks I get 102 - Ticket for another app NOT AUTHENTICATED


  

byte[] ticket = new byte[1024];
        uint pcbTicket = 0;
        HAuthTicket authTicket = SteamUser.GetAuthSessionTicket(ticket, 1024, out pcbTicket);

        if(authTicket == HAuthTicket.Invalid)
        {
            Debug.Log("############# Error getting steam authentication ticket");

        }

        print("SteamUser.GetAuthSessionTicket(Ticket, 1024, out pcbTicket) - " + authTicket + " -- " + pcbTicket);

        EBeginAuthSessionResult ret = SteamUser.BeginAuthSession(ticket, (int)pcbTicket, SteamUser.GetSteamID());
        print("SteamUser.BeginAuthSession(m_Ticket, " + (int)pcbTicket + ", " + SteamUser.GetSteamID() + ") - " + ret);

        string hexEncodedTicket = "";
        for(int i = 0; i < pcbTicket; i++)
            hexEncodedTicket += string.Format("{0:X2}", ticket[i]);

 if I then do  


 

new GameSparks.Api.Requests.SteamConnectRequest()
            .SetDoNotLinkToCurrentPlayer(false)
            .SetErrorOnSwitch(false)
            .SetSessionTicket(sessionTicket)
            .SetSwitchIfPossible(true)
            .SetSyncDisplayName(true)
            .Send((response) => {
                string authToken = response.AuthToken;
                string displayName = response.DisplayName;
                bool? newPlayer = response.NewPlayer;
                GSData scriptData = response.ScriptData;
                var switchSummary = response.SwitchSummary;
                string userId = response.UserId;

            });

 this always returns error 102. What am I missing here? I tried commenting out the BeginAuthSession code, but the result is the same. 



Anders,


Just to be sure, are you logged in to Steam with an account that has access to the game in development?


Cheers,

Jonas

Login to post a comment