Help with fixing error 401

So i was looking into making a program using python that shows me the number of trades I have inbound, and each one’s respective total value, so I looked at the trades api from roblox itself (https://trades.roblox.com/docs#/) and found /v1/trades/{tradeStatusType}/count to be solutions for my project’s first need, the problem is when I was testing with it, it gave me error 401. I searched about it on google (What Is a 401 Unauthorized Error and How Do You Fix It?) and read that it happens when: " The 401 Unauthorized error is an HTTP status that means the page you were trying to access cannot be loaded until you first log in with a valid user ID and password.".

With that said I was wondering if there is a way to verify myself as my account and chekc the number of my trades inbound

Code used to test out :

import requests

x = requests.get(‘https://trades.roblox.com/v1/trades/inbound/count’)

print(x)

response: <Response [401]>

2 Likes

https://auth.roblox.com/docs#!/Authentication/post_v2_login

1 Like

You’ll need to send the .ROBLOSECURITY cookie with the request.

If you do this from your web browser whilst logged in at roblox.com, you’ll see it works - that’s because you have your .ROBLOSECURITY cookie on your browser for .roblox.com addresses.

3 Likes

Hey @kylerzong, I saw the authentication api that you sent me and tried to test it, the problem is that it gave me this error: ({“errors”:[{“code”:0,“message”:“Token Validation Failed”}]}).

This was what I sent in the post: data = {
“ctype” : “Username”,
“cvalue” : “FallenHaunted”,
“password” : not showing to dev forum lol,
}

I didnt put in “captchaToken” or “captchaProvider” because the api said it was optional and didnt put in a description for it except saying it is a string . I would really apreciate if you knew what they meant. :slight_smile:

This is because you didn’t provide a X-CSRF-Token header. It should give back a token in the response headers, so you can just pull it from there and retry the request with the token. You will not get past the robot test though because to do the captcha you need to pass it. It is a robot test for a reason. What most people do (I’m not sure if there is another way) is to just login manually and grab the cookie you get from that and use it for requests your bot request.

@NuclearTheNoob how would I use my cookie as a way to authentify my bot request as myself?

All you have to do is put your cookie in the Cookie request header.

can you show me an example (not with a real cookie), just want to know where would I put that?

I don’t know python but there is a guide to putting headers here. Instead of Accept you’d put Cookie and have your cookie as the value.

Roblox does not use Python. Roblox uses Lua, a completely different programming language.

ok, thanks a lot for the help :slight_smile:

1 Like

ik, but you can still use requests to connect python with roblox

Did you ever manage to get this working?