I want to use roproxy to get a user’s followings. However, it errors with HTTP 401 (Unauthorized).
This is my code:
local function PrintFollowings(Player: Player)
local headers = {
["Cookie"] = ".ROBLOSECURITY=(my cookie)",
["x-csrf-token"] = "(token)",
}
local Success, Result = pcall(function()
local result = HttpService:GetAsync(
"https://friends.roproxy.com/v1/users/" .. Player.UserId .. "/followings",
false,
headers
)
local json = HttpService:JSONDecode(result)
return json
end)
if not Success then
warn("Failed to fetch followings for", Player.UserId, Result)
return
end
print(Result)
end
Am I doing anything wrong? Help would be much appreciated!
Have you tried via the official Roblox APIs rather than roproxy? It’s good to test on your own without a proxy in the middle.
You’d need to, of course, use another way (eg Axios on JavaScript) to fetch the HTTP result though.
Also, why are you using a cookie? Isn’t it safer to use an API key, which roproxy will also accept?
(roproxy is a proxy, so essentially it forwards everything to roblox. that means it should accept the same API keys Roblox does)
So… i’m not exactly sure what the ‘false’ is doing there in your request.
I did some random follower jumping to get a random user ID, and it indeed got their followings without a hassle on the official Roblox endpoint, so I don’t think it’s an issue there.
Maybe it could just be an issue with Roproxy? Try with another cookie on an alt, or another user, and see if that works.
Ah, shame.
Let’s try and see if the issue is isolated to a specific experience, too, now.
We should try testing just the endpoint in another, blank game and see if that works. Do turn on HTTP access, of course.
If it works, that’s great, and the problem is your specific game.
If it doesn’t, then it could be a device thing, since studio is a bit different to live playtime, so we can test in a real game and see if it works.
(We can check using /console, and setting the logs to ‘Server’)
BY THE WAY. For other people having the same problem, please know that the X-Csrf-Token will CHANGE. You will need to Fetch the X-Csrf-Token and use the fetched result to ensure that it doesn’t throw HTTP 401 error again.