How do I log in through Web API with python?


Hey there, I am currently making a discord bot which would allow me to manage a roblox group. For instance, it would rank people.

Nevertheless, I am having some issues with it.
I am relatively new to API programming in python, and, well, I am not really advanced I would say.

The main issue is that I have no idea of how to log in Roblox and bypass Fun Captcha. I mean, I have tried with .ROBLOSECURITY cookie, however as I have said, I am not familiar with API programming and python requests, so I was not able to implement this feature.

Here is the piece of code which gives me problems:

 elif message.content.startswith(prefix + "rbxshout"):
        with requests.Session() as session:
           loginApi = ""
           roblosecurity = "Cookie here"    
           dataToSend = {"message":message.content[len(prefix+"rbxshout"):]}
           cookieData = {".ROBLOSECURITY":roblosecurity}
           tokenN = "Token here"
           auth = {"X-CSRF-TOKEN":tokenN}
           data = session.patch(loginApi, data=dataToSend, headers=auth, cookies=cookieData)
           shout_message = discord.Embed(description="Successfully posted: %s" % message.content[len(prefix+"rbxshout"):],colour=0xff6961,title="New group shout")

I would be really grateful if someone gave me any idea on how to make it work.

PSA: Sorry if this isn’t the right category, I didn’t know where else to put it.


I believe you can ask questions related to the web api of Roblox

But this post might help you


I have already seen that post, and that is how I realized I had to use cookies, however after trying to log in an error pops up:

{‘errors’: [{‘code’: 0, ‘message’: ‘Token Validation Failed’}]}

Just pass a “.ROBLOSECURITY” cookie

I had found a wrong CSFR token, now it works, thank you for your answers.


Good to hear that :slight_smile: