Closed serhaterfidan closed 1 year ago
yes instagram wants change password after request always
@elijah-wright, do we need to add validation when similar cases occur (getting hit with a checkpoint)?
If so, I will try to submit a pull request, or maybe you will be the one working on it?
yes instagram wants change password after request always
Certainly, because Instagram detects unusual activities on your account, that's why it happened.
Damn, your account has been hit with a checkpoint. Please check your Instagram application, you may be required to change your password.
Well, that's a great case to at least handle. Can the error be made to go all the way through to the response at client.login() ? I would definitely expect that kind of behavior so the frontend can display it (especially for my use case)
I can test if you find a solution notify me
when I changed password token got true after request
I can test if you find a solution notify me
The solution is for you to use another Instagram account. Actually, there is no error here, but because you have used it for testing multiple times (requesting login repeatedly), your Instagram account has been hit with a checkpoint. If you use another or a new Instagram account, it will not happen, at least for a few attempts.
when I changed password token got true after request
Of course, because there is nothing wrong. This is just a security measure implemented by Instagram when there is suspicious activity.
i had the same problem as serhat and lol it's a tricky one. i ended up just switching to another account. idk if my old one is still blocked or anything. fwiw, this is also happening to people who don't even use the API because they're switching between two accounts really quickly
feel free to make a pr 👍
feel free to make a pr 👍
At very least, we can only perform validation checks when an account is with a checkpoint.
Same problem here:
/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30
const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0]));
^
TypeError: Cannot read properties of null (reading '0')
at parseBloksResponse (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30:92)
at Client.login (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/index.js:75:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/birobirobiro/Developer/side-projects/threadsjs/index.js:8:3
Node.js v18.16.0
okay I got token but I have a problem here
const user = await client.users.fetch(userId);
{ "message": "Target user not found", "status": "fail" }
is userId a string with a valid userId?
Same problem here:
/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30 const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0])); ^ TypeError: Cannot read properties of null (reading '0') at parseBloksResponse (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30:92) at Client.login (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/index.js:75:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/birobirobiro/Developer/side-projects/threadsjs/index.js:8:3 Node.js v18.16.0
What's more about this? 🥲
is userId a string with a valid userId?
Yes but I realized my threads id not showing on my profile on instagram on my test account but real account it's showing
Yes but I realized my threads id not showing on my profile on instagram on my test account but real account it's showing
Has the Instagram account been registered with Threads? I suspect that the account has not been registered with Threads.
@birobirobiro, can you open /Users/birobirobiro/Developer/side-projects/threadsjs/node/@threadsjs/threads.js/src/util/Bloks.js
and add console.log(tree);
above line 30?
Yes but I realized my threads id not showing on my profile on instagram on my test account but real account it's showing
Has the Instagram account been registered with Threads? I suspect that the account has not been registered with Threads.
Yes I registered I can go instagram also on Threads account but not showing any user id
it's solved user id showing now on my instagram profile but still
{ message: 'Target user not found', status: 'fail' }
await client.users.fetch(userId).then(user => { console.log(user); res.json(user); });
What when the userId is console.log?
How did you resolve?
What when the userId is console.log?
97784297
How did you resolve?
I just refreshed on instagram profile after open Threads app
@birobirobiro, can you open
/Users/birobirobiro/Developer/side-projects/threadsjs/node/@threadsjs/threads.js/src/util/Bloks.js
and addconsole.log(tree);
above line 30?
I`m using the README example:
const { Client } = require('@threadsjs/threads.js');
(async () => {
const client = new Client(
{
token: ''
});
// You can also specify a token: const client = new Client({ token: 'token' });
await client.login('username', 'password');
await client.users.fetch('25025320').then(user => {
console.log(user);
});
})();
function parseBloksResponse(text) {
const { tree } = JSON.parse(text).layout.bloks_payload;
const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0]));
console.log(`tree: ${JSON.stringify(tree)}`);
console.log(`sanitized: ${JSON.stringify(sanitized)}`);
const json = parseNestedJson(sanitized);
return json;
}
❯ yarn start
yarn run v1.22.19
$ node index.js
/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30
const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0]));
^
TypeError: Cannot read properties of null (reading '0')
at parseBloksResponse (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:30:92)
at Client.login (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/index.js:75:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/birobirobiro/Developer/side-projects/threadsjs/index.js:9:3
Node.js v18.16.0
error Command failed with exit code 1.
Try placing console.log(tree) below tree variable.
function parseBloksResponse(text) {
const { tree } = JSON.parse(text).layout.bloks_payload;
console.log(`tree: ${JSON.stringify(tree)}`);
const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0]));
const json = parseNestedJson(sanitized);
return json;
}
97784297
From my account, the response is the same. Can I know the username
Try placing console.log(tree) below tree variable.
function parseBloksResponse(text) { const { tree } = JSON.parse(text).layout.bloks_payload; console.log(`tree: ${JSON.stringify(tree)}`); const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0])); const json = parseNestedJson(sanitized); return json; }
tree: {"㐟":{"#":" (bk.action.core.TakeLast, (bk.action.core.TakeLast, (bk.action.qpl.MarkerAnnotate, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.map.Make, (bk.action.array.Make, \"login_type\", \"login_source\"), (bk.action.array.Make, \"Password\", \"Login\"))), (bk.action.qpl.MarkerAnnotate, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.map.Make, (bk.action.array.Make, \"end_point\"), (bk.action.array.Make, \"generic_error_dialog\"))), (bk.action.qpl.MarkerEndV2, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.i32.Const, 87), (bk.action.tree.Make, (bk.action.i32.Const, 13704)))), null, (bk.action.core.TakeLast, (bk.action.i32.Const, 1), (ig.action.cdsdialog.OpenDialog, (bk.action.tree.Make, (bk.action.i32.Const, 13799), (bk.action.i32.Const, 40), \"Incorrect Password\", (bk.action.i32.Const, 35), \"The password you entered is incorrect. Please try again.\", (bk.action.i32.Const, 36), (bk.action.tree.Make, (bk.action.i32.Const, 13800), (bk.action.i32.Const, 36), \"OK\", (bk.action.i32.Const, 35), (bk.action.core.FuncConst, (bk.action.logging.LogEvent, \"caa_login_client_events_ig\", \"\", (bk.action.map.Make, (bk.action.array.Make, \"core\", \"login_params\"), (bk.action.array.Make, (bk.action.map.Make, (bk.action.array.Make, \"event\", \"event_category\", \"event_flow\", \"event_request_id\", \"event_step\", \"is_dark_mode\", \"exception_code\", \"exception_message\", \"exception_type\", \"extra_client_data\", \"logged_out_identifier\", \"logged_in_identifier\", \"waterfall_id\"), (bk.action.array.Make, \"login_error_dialog_ok_clicked\", \"login_home_page_interaction\", \"login_manual\", \"a24f940c-c6df-465a-befa-223573b3879a\", \"home_page\", (ig.action.IsDarkModeEnabled), (bk.action.i32.Const, 0), \"\", \"\", (bk.action.map.Make, (bk.action.array.Make), (bk.action.array.Make)), \"\", \"\", \"16baceaa-07a1-483e-b112-09a9638fc775\")), (bk.action.map.Make, (bk.action.array.Make), (bk.action.array.Make))))))), (bk.action.i32.Const, 42), (bk.action.i32.Const, 0)), (bk.action.tree.Make, (bk.action.i32.Const, 13808))), (bk.action.core.TakeLast, (bk.action.qpl.MarkerAnnotate, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.map.Make, (bk.action.array.Make, \"login_type\", \"login_source\"), (bk.action.array.Make, \"Password\", \"Login\"))), (bk.action.qpl.MarkerAnnotate, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.map.Make, (bk.action.array.Make, \"end_point\"), (bk.action.array.Make, \"generic_error_dialog\"))), (bk.action.qpl.MarkerEndV2, (bk.action.i32.Const, 2293785), (bk.action.i32.Const, 0), (bk.action.i32.Const, 87), (bk.action.tree.Make, (bk.action.i32.Const, 13704)))), (bk.action.map.Make, (bk.action.array.Make, \"should_dismiss_loading\"), (bk.action.array.Make, (bk.action.bool.Const, false)))))"}}
/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:31
const sanitized = JSON.parse(JSON.parse(Object.values(tree)[0]['#'].match(/\"\{.*\}\"/)[0]));
^
TypeError: Cannot read properties of null (reading '0')
at parseBloksResponse (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/util/Bloks.js:31:92)
at Client.login (/Users/birobirobiro/Developer/side-projects/threadsjs/node_modules/@threadsjs/threads.js/src/index.js:75:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/birobirobiro/Developer/side-projects/threadsjs/index.js:9:3
Node.js v18.16.0
error Command failed with exit code 1.
97784297
From my account, the response is the same. Can I know the username
Client user id and Threads user id is different I didn't find any related info in Client response for Threads
wait I found text_post_app_joiner_number: 97784297,
@birobirobiro You entered the wrong password, buddy. Phew, it seems like we to validate this again.
Client.users not getting Threads user it's getting Instagram user info
Sorry I got it now okay user id is already in the Client object I mixed it Threads id issue resolved thanks guys
Is that correct, I'm using 2FA could this be impacting?
2FA doesn't affect anything, everything has been handled. However, we't handled the incorrect password error yet. In the console.log output you sent, it states that the password is incorrect.
And I am currently trying to find a way to detect it when the password is incorrect.
2FA doesn't affect anything, everything has been handled. However, we't handled the incorrect password error yet. In the console.log output you sent, it states that the password is incorrect.
I put an example token and password to show you how I'm doing it in the code, is that correct?
const { Client } = require('@threadsjs/threads.js');
(async () => {
const client = new Client({
token: '123456',
}
);
// You can also specify a token: const client = new Client({ token: 'token' });
await client.login('birobirobiro', '123456;');
await client.users.fetch('30626776').then(user => {
console.log(user);
});
})();
In client declaration, you don't need to add an object containing the token. Just use const client = new Client({});
and the rest is fine. However, the error occurs because the account password is incorrect.
In client declaration, you don't need to add an object containing the token. Just use
const client = new Client({});
and the rest is fine. However, the error occurs because the account password is incorrect.
I just logged in through the browser using the login and password, the same ones I'm passing in the code and I logged in normally
@elijah-wright Is there no parser outside that can parse the Bloks framework used by Threads and Instagram Lite? This is really stressing me out haha.
Using regex (like in the initial release) is very limited because we only get the, while there is a JSON there that we can all of its contents.
not that i know of
guys token and user coming success on localhost but coming null on Heroku why is that
solved :)
token is getting invaild here how can I pass this part
const token = await getToken(username, password);
instagram logged successful but token is getting null here