Revadike Posted May 9, 2018 Report Share Posted May 9, 2018 (edited) So, I am trying to do some curator stuff with node-steamcommunity.However, for some reason, my simulated requests failed.For example: const formdata = { sessionid: community.getSessionID(), clanid: offer.clanid, appid: offer.appid, action: `accept` }; user.once(`webSession`, () => community.httpRequestPost({ url: `https://store.steampowered.com/curator/${offer.clanid}/admin/ajaxrespondoffer`, form: formdata, // jar: jar, headers: { // ":authority": `store.steampowered.com`, // ":method": `POST`, // ":path": `/curator/${offer.clanid}/admin/ajaxrespondoffer`, // ":scheme": `https`, "Accept": `*/*`, "Accept-Encoding": `gzip, deflate, br`, //"accept-language": `nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7`, "Content-Length": `77`, "Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`, "Cookie": community._jar.getCookieString(`https://store.steampowered.com`), "DNT": `1`, "Origin": `https://store.steampowered.com`, "Referer": `https://store.steampowered.com/curator/${offer.clanid}/admin/pending`, //"user-agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36`, "X-Requested-With": `XMLHttpRequest` } }, acceptedCuratorConnectOffer)); user.webLogOn(); I tried to experiment with headers, but that doesn't seem to do anything. Could it be because of https? Or protocol being h2? Edited May 9, 2018 by Royalgamer06 Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 9, 2018 Report Share Posted May 9, 2018 You're probably meant to send a POST, which it doesn't seem like you're doing. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 9, 2018 Author Report Share Posted May 9, 2018 You're probably meant to send a POST, which it doesn't seem like you're doing.Actually I was, I just forgot to add it to the example code above. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 10, 2018 Author Report Share Posted May 10, 2018 I could setup a teamviewer session, so you can help me debug and fix the problem? I'm really clueless. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 12, 2018 Author Report Share Posted May 12, 2018 I noticed the cookie sessionid and sessionid provided from getSessionID were different. So that's probably it. Now, I have to figure out how to fix and test it. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 13, 2018 Author Report Share Posted May 13, 2018 There are some strange stuff happening. So, I got to admit I am not using community.httpRequestPost, instead I am using my own instance of request, but I do this: user.on(`webSession`, (sessionID, cookies) => { logger.info(`Got steam web session`); community.setCookies(cookies); store.setCookies(cookies); //jar = Object.assign(jar, community._jar); //cookies.forEach(c => jar.setCookie(request.cookie(c), `https://steamcommunity.com`)); // for (let domain in community._jar._jar.store.idx) { // jar._jar.store.idx[domain] = community._jar._jar.store.idx[domain]; // } cookies.forEach(cookie => { jar.setCookie(cookie, `https://steamcommunity.com`); jar.setCookie(cookie, `https://store.steampowered.com`); jar.setCookie(cookie, `https://help.steampowered.com`); }); }); And jar being used in my request defaults: request = request.defaults({ jar: jar, headers: { "User-Agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36`, "Accept-Language": `nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7` }, followAllRedirects: true }), In addition, I use the code posted in the OP (but using my own instance of request).So, here is the weird part. This is the request I end up making: HEADERS { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', 'Accept-Language': 'nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7', Accept: '*/*', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Length': '77', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', Cookie: 'sessionid=6c64xxxac7e2; steamLogin=76561198042965266%7c%7c02106545C272D8AC6FC1D70235CC18D36C89C418; steamLoginSecure=7656119xxx%7c%7c0E7Axxx1F036; browserid=126xxx487; Steam_Language=english; sessionid=6c64xxxc7e2; steamLogin=7656119xxx%7c%7c0210xxxC418; steamLoginSecure=7656119xxx%7c%7c0E7AxxxF036; browserid=126xxx487; Steam_Language=english', DNT: '1', Origin: 'https://store.steampowered.com', Referer: 'https://store.steampowered.com/curator/31xxx23/admin/pending', 'X-Requested-With': 'XMLHttpRequest' } BODY { sessionid: '0252xxx692b', clanid: 31xxx23, appid: 62xx00, action: 'accept' } Notice how the cookies appear twice and the sessionid's are different between headers (pulled from jar) and body (pulled from getSessionID). Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 13, 2018 Author Report Share Posted May 13, 2018 I added some debug to on('webSession') to log its cookies and community and it was different every time.Then I realized it was happening because it wasn't synchronous.Allow me to explain:On every webSession event, the cookies are refreshed and stored. However, I wasn't waiting for this to happen, instead I used webLogon and user.once(`webSession`), which caused my client code to happen simultaneously while cookies are refreshed and stored. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 13, 2018 Author Report Share Posted May 13, 2018 There still seems to be a problem with node-steamcommunity though.Even when I wait for setCookies to take place before I send any http request, community.getSessionID() still manages to return the wrong sessionid. Quote Link to comment Share on other sites More sharing options...
Revadike Posted May 13, 2018 Author Report Share Posted May 13, 2018 I adjusted my code to use sessionid provided by the webSession event instead, and now my code is fully working. Somehow community.getSessionID() was the blame for providing me the wrong sessionid. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.