How can i authenticate for roblox api?

hello, wanted to get my robux but i need to authenticate.

i have tried this in python:

import requests

header = {
    Cookie: ".ROBLOSECURITY_HERE"
}

r = requests.get(url="https://api.roblox.com/currency/balance",headers=header)

print(r)

but it gives this error:

NameError: name 'Cookie' is not defined
1 Like

Should be like this I believe

"Cookie": ".ROBLOSECURITY_HERE"

i have tried that before but it didnt work, it gives error code 403

1 Like

Are you sure your cookie isn’t expired?

how do i check it?
and if it is expired, how do i change it?

1 Like

When you log out, your cookie resets. Assuming your using another account than your main, open a new icognito window (if you’re using chrome) and log in to the account there, take the cookie and close the window.

If it returns code 403 that means you don’t have authorization, aka cookie has expired or is incorrect. You should try what @devjden suggested

it still returns error code 403

1 Like

Just means that the cookie is incorrect. What are you using to grab the cookie?

is used this video:

1 Like

That should work. Is your cookie in this format?
.ROBLOSECURITY=_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_ABCDEF123456789 (Long string of characters)

1 Like

it worked, i forgot to put that in

1 Like

Random question, are you using a site with public projects? If so, you should set your Cookie in a .env file.

am just using https://api.roblox.com/

1 Like

I mean, where are you hosting your project? Like getting your robux balance, where are you writing your code?

am writing my code in visual studio code

Ah okay, sorry. Was just concerned because if this was on an online site like https://repl.it, people could potentially steal your cookie.

1 Like