Jump to content
McKay Development

Send offer get HTTP error 401


Recommended Posts

Hi,

I made this code to send offer but the problem that I got that error "Error: HTTP error 401"

When I using "manager.setCookies" I got the error access denied because my limited account .
So I looked for another module "node-steam-tradeoffers" and it's working with "steam-weblogon" and  "steam-web-api-key" and it's send the offers from my limited account, but I need to using your module, so I made this code which can make the api key.

var Steam = require('steam');
var SteamWebLogOn = require('steam-weblogon');
var getSteamAPIKey = require('steam-web-api-key');
var SteamCommunity = require('steamcommunity');
var SteamTotp = require('steam-totp');
var TradeOfferManager = require('steam-tradeoffer-manager'); 
var fs = require('fs');

//var client = new SteamUser();
var community = new SteamCommunity();
var steamClient = new Steam.SteamClient();
var steamUser = new Steam.SteamUser(steamClient);
var steamFriends = new Steam.SteamFriends(steamClient);
var steamWebLogOn = new SteamWebLogOn(steamClient, steamUser);
var manager = new TradeOfferManager({
  "steam": steamClient, // Polling every 30 seconds is fine since we get notifications from Steam
  "domain": "localhost", // Our domain is example.com
  "language": "en" // We want English item descriptions
});


if (fs.existsSync('polldata.json')) {
  manager.pollData = JSON.parse(fs.readFileSync('polldata.json'));
}

steamClient.connect();
steamClient.on('connected', function() {
  steamUser.logOn({
    account_name: '*********',
    password: '***********',
    two_factor_code: SteamTotp.generateAuthCode('**********************')
  });
});
steamClient.on('logOnResponse', function(logonResp) {
  if (logonResp.eresult == Steam.EResult.OK) {
    console.log('Logged in!');
    steamWebLogOn.webLogOn(function(sessionID, newCookie) {
      getSteamAPIKey({
        sessionID: sessionID,
        webCookie: newCookie
      }, function(err, APIKey) {
       manager.apiKey = APIKey;
        var offer = manager.createOffer("************");
    offer.addMyItem({"appid": 730, "contextid": 2, "assetid": "655530455"});
    offer.send(function(err, status) {
        if (err) {
            console.log("send" + err);
        } else {
            console.log("Offer #" + offer.id + " " + status);
        }
    });
      });
      community.setCookies(newCookie);
    community.startConfirmationChecker(10000, '*********************************');
    });
  }
 });

Link to comment
Share on other sites

  • 3 months later...

You can't use this module with a limited account.

Hello, could you look here? It's seems to be right, but it doesn't conferm trades automaticaly 

var SteamUser = require('steam-user');
var SteamCommunity = require('steamcommunity');
var SteamTotp = require('steam-totp');
var TradeOfferManager = require('../lib/index.js'); // use require('steam-tradeoffer-manager') in production
var fs = require('fs');

var client = new SteamUser();
var offers = new TradeOfferManager({
	"steam": client, // Polling every 30 seconds is fine since we get notifications from Steam
	"domain": "example.com", // Our domain is example.com
	"language": "en" // We want English item descriptions
});
var community = new SteamCommunity();


var logOnOptions = {
	"accountName": "*****",
	"password": "***",
	"twoFactorCode": SteamTotp.getAuthCode("****")
};

if (fs.existsSync('polldata.json')) {
	offers.pollData = JSON.parse(fs.readFileSync('polldata.json'));
}

client.logOn(logOnOptions);

client.on('loggedOn', function() {
	console.log("Logged into Steam");
});

client.on('webSession', function(sessionID, cookies) {
	offers.setCookies(cookies, function(err) {
		if (err) {
			console.log(err);
			process.exit(1); // Fatal error since we couldn't get our API key
			return;
		}

		console.log("Got API key: " + offers.apiKey);
	});

	var trade = offers.createOffer("76561197982243076");


	offers.loadInventory(570, 2, true, function(err, myItems) {
		if(err) {
			console.log(err);
			return;
		}

		trade.loadPartnerInventory(570, 2, function(err, theirItems) {
			if(err) {
				console.log(err);
				return;
			}

			trade.addMyItem(myItems[0]);
			//trade.addMyItem({"appid": "570","contextid": "2", "assetid": "994253688"  });
			trade.addTheirItem(theirItems[0]);
			trade.send(function(err, status) {
				if (err) {
					console.log("send" + err);
				} else {
					console.log("Offer #" + trade.id + " " + status)
				}
			});
		});

	});

	community.setCookies(cookies);
	community.startConfirmationChecker(30000, "identitySecret"); 
});

And could you say, how bot can get assetid of item and whan I use "id" from http://steamcommunity.com/profiles/76561198106184535/inventory/json/570/2 it brings error(26)

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