Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #223 from Aerglonus/fixes
Browse files Browse the repository at this point in the history
Fix: getToken not returning userID
  • Loading branch information
junhoyeo authored Jul 20, 2023
2 parents 75a1e10 + 90db5ff commit f88a75a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions threads-api/src/threads-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ export class ThreadsAPI {
`${BASE_API_URL}/api/v1/bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/`,
requestConfig,
);

data = JSON.stringify(data.replaceAll('\\', ''));

if (this.verbose) {
Expand All @@ -399,7 +400,7 @@ export class ThreadsAPI {

try {
const token = data.split('Bearer IGT:2:')[1].split('"')[0].replaceAll('\\', '');
const userID = data.match(/pk_id":"(\d+)/)?.[1];
const userID = data.match(/pk_id(.{18})/)?.[1].replaceAll(/[\\":]/g, '');

if (!this.noUpdateToken) {
if (this.verbose) {
Expand Down Expand Up @@ -498,7 +499,6 @@ export class ThreadsAPI {
...(!!username ? { referer: `https://www.threads.net/@${username}` } : undefined),
});

//BUG RETURNS 404 NOT FOUND
getProfilePage = async (url: string, username: string, options?: AxiosRequestConfig) => {
const res = await axios.get(`${url}${username}`, {
...options,
Expand Down Expand Up @@ -550,7 +550,7 @@ export class ThreadsAPI {

return userID;
};
//BUG: RETURNS "DATA: '' WITH ERROR 429 TOO MANY REQUESTS"

getUserIDfromUsername = async (
username: string,
options?: AxiosRequestConfig,
Expand Down

0 comments on commit f88a75a

Please sign in to comment.