What I’m trying to do is execute JavaScript code in my browser to send a GET request to the Roblox API https://economy.roblox.com/v1/user/currency to grab the Robux (In-game currency of the game Roblox) amount in my Roblox account. The problem is that when I have a tab of roblox.com open and I execute the JavaScript code to grab the Robux amount, the requests to the API will not be authenticated. (missing .ROBLOSECURITY session cookie in the request)
The thing is, having a tab of economy.roblox.com open will allow the requests to /v1/user/currency to be authenticated, but I need to be on the roblox.com site to do the task that I have. Is there any way to send authenticated requests to economy.roblox.com while being in roblox.com?
And no, I can’t just grab the .ROBLOSECURITY cookie of my account then manually include it in the JavaScript code to send it to the API, there’s a reason why I can’t do this.
One approach I had in mind was to make the JavaScript code redirect me or open a tab of economy.roblox.com for a split second to send the API request, then redirect back to the roblox.com url that I was in, but this didn’t work as normal browser behaviour stops the rest of the JavaScript code from executing if I was redirected to another url.
2
Answers
I’ve been tinkering with a similar issue for the past few days and here is a solution I came up (full credit to Julli4n on Github for the bat generation code)
Requests on Roblox that require user authentication now need a bat token in the headers, this is part of a new Roblox update to increase account security, read more about it here
No. What you want is cross-site request forgery, an attack technique used by hackers. This is incredibly sketchy and should never be done by a legitimate website.