Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Where can I find my Csrf token?

I need it to run a group promotion api. I have the change rank already running aswell as the in-game script. Just can't find my csrf token.

1 comment

2

I see you're going for guesswork by method of buzzword today.

1 answer

✓ Accepted answer

You can get a CSRF token by posting to the sign-out endpoint at https://api.roblox.com/sign-out/v1 - The post will fail and the failure response will include the CSRF token in the headers. You'll need to include the cookie container from your login process. Here is an example using HttpClient in C#

public string GetToken()
{
    //this doesn't actually log out, but fails with a header including the token desired
    String url = "https://api.roblox.com/sign-out/v1";
    string result = null;
    using (var handler = new HttpClientHandler() { CookieContainer = _cookieContainer, UseCookies = true })
    using (var client = new HttpClient(handler))
    {
        var response = client.PostAsync(url, null).Result;
        result = response.Headers.GetValues("X-CSRF-TOKEN").FirstOrDefault();
    }
    return result;
}

This discussion is preserved as it was. New answers, comments, and votes are closed.