samcday / deathbycaptcha.js

DeathByCaptcha for Node.js
Other
7 stars 1 forks source link

403 (Invalid Login / Insufficient Credits) #2

Closed rannmann closed 10 years ago

rannmann commented 10 years ago

I've used this module in the past and had no issues, but the exact same code seems to be failing now. I can still log in to DBC and check my balance, but when an image is submitted (only tested by stream), the response is always a 403 Forbidden. I've taken the issue up with support, and they said it's not an issue on their end (still skeptical about that). I tested with the command line tool they provide, and it seems to work fine.

I'm not sure if something changed in the past month or two in their API, but from reading the docs it seems like it should work. Below is a captured POST request for reference.

{
    url: 'http://api.dbcapi.me/api/captcha',
    headers: {
        'content-type': 'multipart/form-data'
    },
    multipart: [  
        {
            'content-disposition': 'form-data; name="captchafile"; filename="captcha"',
            'content-type': 'application/octet-stream',
             body: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 d3 00 00 00 28 08 02 00 00 00 eb 30 58 54 00 00 18 c1 49 44 41 54 78 9c ed 9c 57 7b 1b 57 9a e7 ...>
        },
        {
            'content-disposition': 'form-data; name="username"',
            body: 'REDACTED'
        },
        {
            'content-disposition': 'form-data; name="password"',
            body: 'REDACTED'
        }
    ]  
}
samcday commented 10 years ago

Hello, perhaps they have updated their API? I haven't worked on or used this library in quite some time, so I'm unsure what the state of it is.

samcday commented 10 years ago

Closing this due to no response.

yicone commented 10 years ago

I also encountered this problem. That is my solution by some of try, and I think this manner of use RequestJS for multipart post is more simpler.

// img = fs.createReadStream(imgPath)
DeathByCaptcha.prototype.solve = function(img, cb) {
      var _this = this;
      var r = request.post({
          uri: 'http://api.dbcapi.me/api/captcha'
      }, function(err, resp, body){
         // no different!
      });
      var form = r.form();
      form.append('username', this.username);
      form.append('password', this.password);
      form.append('captchafile', img);

      return r;
}
samcday commented 10 years ago

@yicone nice work, could you submit a pull request that fixes the issue? I'll merge it in and make a new release straight away.