Roblox API keeps giving me "Token Validation Failed"?

Hello, I am trying to get an authorization token for Roblox, but it doesn’t seem to work. It keeps giving me the “Token Validation Failed” error. I am using Python and this is my script:

import requests

ROBLOSECURITY = "_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_OMEGALUL"

cookies = {'.ROBLOSECURITY': ROBLOSECURITY}

session = requests.Session() session.cookies[".ROBLOSECURITY"] = ROBLOSECURITY req = session.post(url="https://auth.roblox.com/v2/logout")

session.headers["X-CSRF-TOKEN"] = req.headers["X-CSRF-Token"]

req2 = session.post(url="https://auth.roblox.com/v1/authentication-ticket")

print(req.content)

What am I doing wrong? Please help me with this.

Thanks, Dragon

1 Like

btw it prints this

b’{“errors”:[{“code”:0,“message”:“Token Validation Failed”}]}’

This is because you are sending the logout request without a CSRF token.
If it gives you a Token Validation Failed error, it sends the CSRF token anyways.

The code seems to be fine, request 2 should work as request 1 gave the token.

(Print out req2’s content, it should succeed)

Oh wow, I was printing request 1’s content. I’m an idiot. Request 2 doesn’t work still though, it gives me this as it’s content:

The UrlReferrer was invalid or came from outside Roblox.

b’{“errors”:[{“code”:2,“message”:“The UrlReferrer was invalid or came from outside Roblox.”,“userFacingMessage”:“Something went wrong”}]}’

Set the “Referer” header to “https://www.roblox.com

2 Likes

You never put a valid .roblosecurity. So do so

Thank you so much! It finally worked!

His ROBLOSecurity is valid, he just removed the actual string so he doesn’t leak it

1 Like