Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Where can I find my Csrf token?

Asked by 7 years ago

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.

2
I see you're going for guesswork by method of buzzword today. User#6546 35 — 7y

1 answer

Log in to vote
1
Answered by
AxeOfMen 434 Moderation Voter
7 years ago

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;
}
Ad

Answer this question