Open Pleiode opened 3 weeks ago
Hey,
I have a function to post image on instagram with text.
I recently changed my instagram username and I've had ‘400 Bad Request; challenge_required’ ever since.
Yet all my connection info is good, I checked.
I also confirmed that I was the one who logged into Instagram when he asked if it was me, given a new connection.
const IG_USERNAME = "****"; const IG_PASSWORD = "****"; [...] const postToInsta = async (randomImageDoc, description) => { return retry(async () => { const ig = new IgApiClient(); ig.state.generateDevice(IG_USERNAME); console.log('Attempting to login to Instagram with username:', IG_USERNAME); await ig.account.login(IG_USERNAME, IG_PASSWORD); console.log('Logged in to Instagram successfully'); const { imageUrl, username, objects } = randomImageDoc; console.log('Fetching image from URL:', imageUrl); const imageBuffer = await axios.get(imageUrl, { responseType: 'arraybuffer' }).then(response => response.data); console.log('Image fetched successfully'); const caption = `${description}\n\nCosmio's Image of the Day: shot by ${username}\n\nExplore space on Cosmio.io\n\n#astrophotography #astrophoto #astronomy #astro #cosmio #imageoftheday #space #nightsky #telescope #universe #stargaze #nightphotography #cosmos`; console.log('Caption:', caption); console.log('Attempting to publish photo to Instagram'); await ig.publish.photo({ file: imageBuffer, caption: caption }); console.log('Photo published successfully'); console.log('Marking the image as posted in Firestore'); await admin.firestore().collection('images').doc(randomImageDoc.id).update({ posted: true }); console.log('Image marked as posted in Firestore'); }); };
In my console Firebase Functions
DEFAULT 2024-10-01T12:06:35.264569Z at Request.send (/workspace/node_modules/instagram-private-api/dist/core/request.js:54:28) DEFAULT 2024-10-01T12:06:35.264564Z at Request.handleResponseError (/workspace/node_modules/instagram-private-api/dist/core/request.js:108:24) DEFAULT 2024-10-01T12:06:35.264544Z Attempt 2 failed: IgCheckpointError: POST /api/v1/accounts/login/ - 400 Bad Request; challenge_required
There are many challenge types
Hey,
I have a function to post image on instagram with text.
I recently changed my instagram username and I've had ‘400 Bad Request; challenge_required’ ever since.
Yet all my connection info is good, I checked.
I also confirmed that I was the one who logged into Instagram when he asked if it was me, given a new connection.
My code
Error
In my console Firebase Functions