Follow player using Roblox web API

  1. What do you want to achieve? I want to follow a player using the roblox web api

  2. What is the issue? I can’t get the x-csrf-token

  3. What solutions have you tried so far? I have tried this:

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

session = requests.Session()
session.cookies[".ROBLOSECURITY"] = cookie
session.headers["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0"

playerId = input('PlayerId to follow> ')

first_attempt = session.post(f"https://friends.roblox.com/v1/users/{playerId}/follow")

print(first_attempt)

if first_attempt != 200:
    for i in first_attempt.headers:
        if i.lower() == "x-csrf-token":
                session.headers[i] = first_attempt.headers.get(i)

second_attempt = session.post(f"https://friends.roblox.com/v1/users/{playerId}/follow")

print(second_attempt)

When running the script the following gets printed into the console:

PlayerId to follow> 1
<Response [403]>
<Response [403]>

I don’t know why this does not work. Please help!