RoZod handles Roblox authentication automatically with comprehensive security features including CSRF tokens, hardware-backed authentication (HBA), and challenge handling. Authentication works differently depending on your environment.
In browser environments, RoZod automatically uses the user’s Roblox session cookies. No configuration needed:
import { fetchApi } from 'rozod';import { getUsersUserdetails } from 'rozod/lib/endpoints/usersv1';// Cookies sent automatically - works if user is logged into Robloxconst userInfo = await fetchApi(getUsersUserdetails, { userIds: [123456] });
For Node.js, Bun, or Deno, use configureServer() to set up authentication:
import { configureServer, fetchApi } from 'rozod';import { getUsersUserdetails } from 'rozod/lib/endpoints/usersv1';// Configure once at application startupconfigureServer({ cookies: process.env.ROBLOX_COOKIE});// All subsequent requests include the cookie automaticallyconst userInfo = await fetchApi(getUsersUserdetails, { userIds: [123456] });
Never commit .ROBLOSECURITY cookies to version control. Always use environment variables or secure credential storage.
Provide the cookie value without the .ROBLOSECURITY= prefix:
// Correct:configureServer({ cookies: '_|WARNING:-DO-NOT-SHARE-THIS.--Cookies...'});// Also works with prefix (automatically stripped):configureServer({ cookies: '.ROBLOSECURITY=_|WARNING:-DO-NOT-SHARE-THIS...'});
import { refreshCookie, getCookies, updateCookie } from 'rozod';// Refresh the first cookieconst result = await refreshCookie(0);if (result.success) { console.log('New cookie:', result.newCookie); await database.save(result.newCookie);} else { console.error('Refresh failed:', result.error);}// Refresh all cookies in poolconst cookies = getCookies();for (let i = 0; i < cookies.length; i++) { await refreshCookie(i);}
import { updateCookie } from 'rozod';// Update cookie at index 0updateCookie(0, 'new_cookie_value');// Update a specific account in a poolupdateCookie(2, 'new_cookie_for_account_3');
import { getServerConfig, clearServerConfig } from 'rozod';// Get current configuration (read-only)const config = getServerConfig();console.log(config.cookies);console.log(config.cloudKey);console.log(config.cookieRotation);// Clear all configurationclearServerConfig();