jlobos / instagram-web-api

🤳 Instagram Private Web API client for Node
https://npmjs.com/instagram-web-api
MIT License
1.12k stars 186 forks source link

upload photo 403 status #177

Closed TchernyavskyDaniil closed 4 years ago

TchernyavskyDaniil commented 4 years ago

https://gist.githubusercontent.com/TchernyavskyDaniil/4563e3c2c75a94ff23c0fa6be9a0f8f3/raw/23a5636ca5ff4959dc106a690d1cfd018b3cf0b2/err.js

I receive this message when I try to upload an image. The code below. What am I doing wrong?

const photo =
    'https://upload.wikimedia.org/wikipedia/commons/3/3f/JPEG_example_flower.jpg';  
await client.uploadPhoto({ photo, caption: '❤️', post: 'feed' });
codexJoin commented 4 years ago

So, I tested the upload now with this same image and it worked, maybe you tried to upload it many times. For me it worked correctly, error 403 is access denied, permission denied.

NOTE 1: The image is small, so instagram deletes it after uploading, if you tried to upload it several times you will receive error 403.

Img of the upload: https://prnt.sc/u9ct7a Img of the configure response: http://prntscr.com/u9ctze

My code with success response:


(async() => {

    await client.login({username: '************', password: '****************});

    const photo = 'https://upload.wikimedia.org/wikipedia/commons/3/3f/JPEG_example_flower.jpg';

    const test = await client.uploadPhoto({ photo, caption: 'testing', post: 'feed'});

    console.log(test);

})();
TchernyavskyDaniil commented 4 years ago

@codexJoin Thank you. Everything is cool. The only thing that is not yet clear is why every time a code asks for it. I guess it's okay. But what is the option in the future without the code to come in?

const login = async () => {
  const insta = new Instagram({
    username: mockUsername,
    password: mockPassword,
  });

  try {
    await insta.login();
  } catch (err) {
    if (err.error && err.error.message === 'checkpoint_required') {
      const challengeUrl = err.error.checkpoint_url;

      await insta.updateChallenge({ challengeUrl, choice: 1 });

      const reader = require('readline-sync');
      const code = reader.question('Code: ');

      await insta.updateChallenge({ challengeUrl, securityCode: code });
    } else {
      console.error(err);
    }
  }

    return insta;
};

const client = await login();

await client.login({
  username: mockUsername,
  password: mockPassword,
});

await client.changeProfilePhoto({
  photo: someDirPhoto,
});
codexJoin commented 4 years ago

There is probably an incompatibility with this code of yours in the redirection part with the new image upload system, I already have an idea of ​​what it might be, I will work on it and later put a solution.

About your question, this "block" is by instagram, and can't not be patched, challenge is every required if your account have suspect activity