Closed JakeCooper closed 9 years ago
I was getting a 403 error a while ago. I found that this is occurs when you attempt to send a steam message or trade offer before being successfully logged in. Try having your program wait 5 seconds before getting offers and see if that works.
Well thing is, I can send tradeOffers fine, I just can't pole the offer using the getOffer command, so I don't think its an issue of not being signed in.
Yes that is strange. I'll try your code any see what happens for me. It could just be that the steam inventory servers are down or slow at he moment.
But also weird, because my alt account works, but not the bots.
I think I found your issue. When I used your code with a random string of numbers for the tradeOfferId, I too got an error 403. However, after using a tradeOfferId that I had just sent, I received the correct output.
My guess is that you are trying to use a tradeOfferId from your alt account with your bots. Your bots can only check their own trade offers, so try using a tradeOfferId that you're sure your bot has and see if that works.
The trade offer ID is generated in the callback for the makeOffer call, so I don't think that's it.
steamOfferObj.makeOffer({
partnerSteamId : steamID,
accessToken : userAccessToken,
itemsFromMe: '{}',
itemsFromThem: objectArray
}, function(err, data) {
console.log(err);
console.log(data);
var start = Date.now();
function getData() {
var setTimer = setTimeout(getData, 10000);
if (Date.now() - start > 300000){
steamOfferObj.cancelOffer({
tradeOfferId: data["tradeofferid"]
}, function(){
clearTimeout(setTimer);
eventEmitter.emit('requestOfferExpired');
return;
})
}
steamOfferObj.getOffer({
"tradeOfferId": data["tradeofferid"] // The tradeoffer id
}, function(error, body) {
console.log(body);
console.log(error);
if (error == null) {
//console.log(body);
console.log(body.response.offer.trade_offer_state);
if (body.response.offer.trade_offer_state == 3) {
eventEmitter.emit('requestOfferAccepted');
clearTimeout(setTimer);
return "Offer Accepted" //on accept
} else if(body.response.offer.trade_offer_state == 7){
eventEmitter.emit('requestOfferExpired');
clearTimeout(setTimer);
return "Offer cancelled";
} else {
}
}
});
}
getData();
})
Try outputting that tradeOfferId to the console and make sure it looks reasonable. I'm almost sure the 403 has to do with some error with the tradeOfferId.
The one from my alt: http://i.imgur.com/zDOYY7Q.png
The one from my bot: http://i.imgur.com/HCOV2Ys.png
Seems reasonable to me.
This seems to work perfectly for me:
function getData() {
setTimeout(function () {
offers.makeOffer({
partnerSteamId: "76561198092490523",
itemsFromMe: [ // make sure you have the square brackets
{
"appid": 440,
"contextid": 2,
"amount": 1,
"assetid": "3585401379"
}
],
itemsFromThem: {}
}, function(err, data) {
console.log(data);
console.log(err);
offers.getOffer({
"tradeOfferId": data["tradeofferid"] // The tradeoffer id
}, function(error, body) {
console.log(body);
console.log(error);
if (error == null) {
console.log(body.response.offer.trade_offer_state);
if (body.response.offer.trade_offer_state == 3) {
return "Offer Accepted"; //on accept
} else if(body.response.offer.trade_offer_state == 7){
return "Offer cancelled";
} else {
//do something
}
}
});
});
}, 5000);
}
What did you change there?
Doesn't seem to be working with my bot account, but that code does work on my alt.
I didn't change much there. It seems, though, that the error is on the bot's side. Have you disabled email confirmation for the bot? Has it been logged in from your Node-Steam for at least 7 days?
The trade requests seem to send off fine, I just can't poll the trades. It's incredibly odd. Bots have a scraper that activates when the email comes in and auto verifies the trade, and the trades seem to send out fine so its not that, or the 7 day thing.
Spent a couple hours last night trying to tweak it but came up dry.
Very odd. Hopefully someone more knowledgeable can shed some light on this.
I think i found the reason for 403 problem. it's related to the apikey. The getOffer or getOffers method do not get apikey for you. You need to call SteamTradeOffers.prototype.getAPIKey for youself before you call the getOffer. Anyway,this solves my 403 problem. the latest version do get apikey automatically, i should update my package.
@l419351633 There is no SteamTradeOffers.prototype.getAPIKey
and never was, what version you are using? getAPIKey
function is not exposed to users.
@Alex7Kom When I was using 1.0.3 version, the 403 problem was fixed by the getAPIKey. And i thought the 403 problem should be related to the apikey issues. The apikey relates to the account,so different accounts show different results.
So I am able to getOffers when I run my brothers account (Which has games, playtime, etc), but when I run my bots, I get this 403 error.
Seems to be related to these, but I've tried everything suggested:
https://github.com/Alex7Kom/node-steam-tradeoffers/issues/32 https://github.com/Alex7Kom/node-steam-tradeoffers/issues/48
Here's my code