Reputation: 31
I recently started to work with the roblox api, It's been going good so far but I can't login. I tried to set the cookie by doing apiCall.headers.set-cookie = cookie
, But that doesn't seem to work. How can I solve this issue?
Would I have to get set-cookie then edit it? i.g
const cookieSet = await apiCall.headers.get("set-cookie")
cookieSet = cookie
If I made it difficult to understand, I'll try to make it more clear How would I post a cookie to a roblox API?
My code:
if (!cookie.startsWith("_|WARNING:")) {
throw new Error("Make sure your token is correct")
}
const cookies = {
headers: {
cookie: cookie
}
}
await fetch("https://www.roblox.com", cookies)
const thing = await fetch('https://api.roblox.com/currency/balance', cookies).then(res => res.json())
console.log(thing)
Thing outputs : { errors: [ { code: 403, message: 'Forbidden' } ] }
Upvotes: 2
Views: 4670
Reputation: 31
Well turns out I had to access the cookie from the Header. I did so by doing
const apiCall = await html.func("api.roblox.com/currency/balance", {
headers: {
cookie: `.ROBLOSECURITY=${cookie}`
}
})
Thanks for those who tried to help me!
Upvotes: 1