I am trying to make a python program on my computer that will send a trade once I enter in some information. Whenever I make the request to send a trade, the status_code of that request prints as ‘401’ which when looking it up on https://trades.roblox.com/docs#!/Trades/post_v1_trades_send, it says that ‘Authorization has been denied for this request.’ My ROBLOSECURITY is in a different module and the send_trade function is running from a different module. How do I prevent this error? Am I entering in something incorrectly? I have the x-csrf-token and my ROBLOSECURITY so I don’t know what’s wrong.
My code: (‘roblox’ module)
import settings, httpx, json, requests
logout_data = { #this is for getting the x-csrf-token
'Accept': 'application/json',
'Cookie': ".ROBLOSECURITY="+settings.settings['cookie'] #ROBLOSECURITY is posted in my settings module (I don't want to show it here)
}
h = requests.post("https://auth.roblox.com/v2/logout",headers=logout_data)
#print(h.headers["x-csrf-token"])
async def send_trade(data): #function is being called from another module
requested = requests.post("https://trades.roblox.com/v1/trades/send", data, settings.settings['cookie'], headers = {
"Content-Type": "application/json",
"X-CSRF-TOKEN": h.headers["x-csrf-token"]
})
print(requested.status_code) # Prints as 401 ('Authorization has been denied for this request')
From my main module that is calling the send_trade function.
data = json.dumps({ #lowercase json
"offers": [
{
"userId": TargetUserId, # UserID of the person to send the trade to
"userAssetIds": RequestItems, #Items you want to request
"robux": RequestRobux # Amount of robux to request
},
{
"userId": settings.settings["userId"], # My userId
"userAssetIds": GiveItems, #Items to give
"robux": GiveItems # Amount of robux to give
}
]
}, separators=(',', ':'))
asyncio.run(roblox.send_trade(data))