Jump to content
McKay Development

Identical http request returns success: 2 (generic fail) instead of success: 1


Revadike
 Share

Recommended Posts

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 by Royalgamer06
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...