Godotsteam: Need to access underlying ticket struct

Created on 13 Sep 2019  ·  12Comments  ·  Source: Gramps/GodotSteam

Hello @Gramps . Just started using Godot and I'm a big fan of your work. I have a problem though, I want to validate the AuthSessionTicket that getAuthSessionTicket() retrieves. Unfortunately inorder to do that on a server (via steams web api) it seems I need access to the underlying buffer and size variable in the struct. Do you have any existing methods to access these?

https://github.com/Gramps/GodotSteam/blob/49742f8566de8f324a0aae8bd7da6201d5189789/godotsteam/godotsteam.h#L383

question server

All 12 comments

Hey there and thank you, sir! Hmm, I believe those were added in as a pull request a while back but this seems like a good time to dig into and finish the Users stuff!

Looking at the current function, it seems to just pass back the ID. Since the ticket data struct is mostly just used for internal purposes, you could try modifying the getAuthSessionTicket() function to get the data you want:

Dictionary Steam::getAuthSessionTicket(){
    Dictionary ticket_data;
    if(SteamUser() == NULL){
        return ticket_data;
    }
    uint32_t ticketSize = 1024;
    uint32_t *buffer = memnew_arr(uint32_t, ticketSize);
    uint32_t id = SteamUser()->GetAuthSessionTicket(buffer, ticketSize, &ticketSize);
    // Pass data to TicketData struct for later use
    TicketData ticket = { id, buffer, ticketSize };
    tickets.push_back(ticket);
    // Create dictionary to return this ticket
    ticket_data["id"] = id;
    ticket_data["buffer"] = buffer;
    ticket_data["size"] = ticketSize;
    return ticket_data;
}

This is pretty hacked together and I haven't tested it; however, it does seem to compile OK. You'll also want to change line 291 in the godotsteam.h file to:

Dictionary getAuthSessionTicket();

Let me know if this works for you. I don't know too much about cross-play between the Steam web API and the Steamworks C++ stuff but hopefully this works for you!

Thanks for the quick response. I tried your proposed update and it almost worked, but it seems that I didn't actually receive the buffer using GDscript. (Not exactly sure how this works so let me know if you think it would work in GDNative or C#).

My code:

func _ready():
    _init_steam()
    SESSION_TICKET = Steam.getAuthSessionTicket()
    print(SESSION_TICKET)
    print(typeof(SESSION_TICKET["buffer"]) == TYPE_BOOL)
    Steam.connect("get_auth_session_ticket_response", self, "_get_auth_session_ticket_response")

With an output of this:

{buffer:True, id:10, size:234}
True

EDIT: P.S. My exact intended goal is to validate the retrieved ticket for auth purposes on the server via this endpoint: https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1/?ticket={TICKET_VALUE}&.... Unfortunately it seems like it requires slightly more manipulation (as described below), so I'm not sure if this would be better sent with dict["web_api_format"] as the formatted string instead of the buffer key since I don't know how good GDScript is at handling the raw data in the buffer? From lots of googling it seems others in the C# world have also encountered similar issues.

Convert the ticket from GetAuthSessionTicket from binary to hex into an appropriately sized byte character array and pass the result in as this ticket parameter.

Welcome! Hmm, the buffer might need converted. I know with the avatar image data that comes back as a buffer it has to be processed to output the image; granted this is way different than image data. After looking over the stuff for the Steam API authentication, I see why it is set up the way it is as it just keeps an internal list of that data but getting the auth tickets is still useful.

I might have to look at the Steam web API stuff to figure it out a bit better. I'll dig into this over the weekend and see what I can't find out.

That makes sense. I really don't need to validate the user (plenty of other stuff to do) so no rush but I do think it will be a nice to have eventually.

Fair enough. Hopefully I'll have time tomorrow evening while compiling Linux versions to really read it over and think of a solution.

Hey there! Still haven't had much luck pulling the data out but am going to try some new tricks this weekend. Wanted to let you know I am still plugging away at it when I have time.

Thank you!

Working on some authorization stuff this weekend and hopefully will have a solution for this. I know there are some callbacks missing so hopefully I can get them all sorted out then.

Hey there! I added a new function called getAuthSessionTicketID which should return the ticket as a dictionary. Let me know if that works for you. If so I'll change the names around with getAuthSessionTicket so they are accurate.

Going to swap the names around in GodotSteam 3.4.2, so keep an eye out for that. I will close the issue for now unless you find the new function doesn't give you the information you need.

Okay awesome thank you Gramps. Haven't had the opportunity to try this yet.

No problem! Hopefully it does what you require. If not, re-open the issue and we'll sort it out.

Was this page helpful?
0 / 5 - 0 ratings