Steamworks user_get_auth_session_ticket()

I’m not sure how to use the steamworks.user_get_auth_session_ticket() function. Here is the source:

static int ISteamUser_GetAuthSessionTicket(lua_State* L) {
int top = lua_gettop(L);
uint32 pcbTicket = check_uint32(L, 3); /*out_param*/
int cbMaxTicket = check_int(L, 2); /*normal*/
dmScript::LuaHBuffer * pTicket_buffer = check_buffer(L, 1); /*buffer_param*/
void * pTicket = 0x0;
uint32_t pTicket_buffersize = 0;
dmBuffer::Result pTicket_buffer_result = dmBuffer::GetBytes(pTicket_buffer->m_Buffer, (void**)&pTicket, &pTicket_buffersize);

HAuthTicket r = user->GetAuthSessionTicket(pTicket, cbMaxTicket, &pcbTicket);
push_HAuthTicket(L, r);
push_uint32(L, pcbTicket); /*out_param*/

assert(top + 1 + 1 == lua_gettop(L));
return 1 + 1;
}

Could someone who understands the C++ <-> Lua API explain what kind of arguments are required? I am attempting to get the current auth session ticket so I can link the player’s Steam account with their PlayFab account.

What does the Steam API docs say for the SteamUser GetAuthSessionTicket() function?

It is this one here: ISteamUser Interface (Steamworks Documentation)

The variable types are different than Lua, so I am not entirely sure what the Lua port is expecting.

The auto generated bindings are terrible to be honest. The Steamworks API is not meant to be used in any other way than from C++ and attempts to automatically create bindings from the API definition will be messy.

The first argument should be a Lua buffer. Created using buffer.create(). Stream name doesn’t matter.

Second argument should be the length of the buffer.

Third argument can be 0.

The buffer will contain the auth ticket and the function will return a handle to the auth ticket and the length of the ticket.

As per the documentation you need to call CancelAuthTicket with the handle once you are done with it.

1 Like

Okay, I’m a little lost…

Here’s what I have for creating the buffer:

	session_ticket_buffer = buffer.create(128, { { name = "default", type = buffer.VALUE_TYPE_UINT8, count = 1 } })
	steamworks.user_get_auth_session_ticket(session_ticket_buffer, 128, 0)

I don’t think I have those arguments correct… Printing out the contents of the buffer with buffer.get_bytes() a few seconds later prints an empty string to the console, and the auth ticket handle returned by user_get_auth_session_ticket() is 0, which implies an error.

Please create a ticket in the repo and I’ll take a look

1 Like

The issue is posted here: https://github.com/britzl/steamworks-defold/issues/29

1 Like