Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIKI] Add info on how to convert Steam Auth Ticket for Web Api to hex string #104

Closed
KhanDevelopsGames opened this issue Nov 12, 2024 · 1 comment
Assignees

Comments

@KhanDevelopsGames
Copy link

KhanDevelopsGames commented Nov 12, 2024

The wiki for steam_user_get_auth_ticket_for_web_api lacks important info on how to convert the received byte array to a hex string. I was able to do it myself after a few hours, but adding the information to the wiki directly will save the time of a lot of devs.

Here is the code i have used, should it be of any help:

Convert Functions:

function steam_auth_bufferToHex(_buffer)
{
	if(!buffer_exists(_buffer))
	{
		return "BUFFER NOT AVAILABLE";	
	}
	
	var _hexString = "";
	var _byte = 0;
	var _bufferSize = buffer_get_size(_buffer)
	buffer_seek(_buffer, buffer_seek_start,0);	
	for(var _i = 0; _i<_bufferSize;_i++)
	{			
		_byte = buffer_read(_buffer, buffer_u8);
		_hexString += byte_to_hex(_byte);			
	}		
	return _hexString;
}

function byte_to_hex(_byte)
{
	var _initialValue = string(ptr(_byte));
	if(_initialValue = "null")
	{
		return "00";	
	}	
	return string_delete(_initialValue,1,string_length(_initialValue)-2)
}

Aync - Steam Event:

//handle Steam auth
var _event = async_load[?"event_type"];
if(_event = "ticket_for_web_api_response")
{
	var _success = async_load[?"success"];	
	if(_success)
	{
		var _receivedTicketBuffer = async_load[?"auth_ticket_buffer"];		
		var _hexString = steam_auth_bufferToHex(_receivedTicketBuffer);		
		scr_server_account_loginWithSteam(_hexString); //Send HTTP request with your hex converted Auth Ticket to your Server	
	}
	else
	{
		steam_user_cancel_auth_ticket(user_receiveSteamWepApiTicket); //Cancel the auth ticket if something goes wrong.
	}
}
@KhanDevelopsGames KhanDevelopsGames changed the title [WIKI] Add info on how to convert Steam byte array to hex string [WIKI] Add info on how to convert Steam Auth Ticket for Web Api to hex string Nov 12, 2024
@stuckie stuckie moved this from Triage to Backlog in Team Workload Nov 13, 2024
@DiasFranciscoA
Copy link
Collaborator

This as been added to both the WIKI and offline docs (available on next relase of steamwork)

@github-project-automation github-project-automation bot moved this from Backlog to Done in Team Workload Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants