subzeroid / instagrapi-rest

RESTful API Wrapper for Instagram Private API
https://hikerapi.com/p/ygXxF38v
MIT License
499 stars 128 forks source link

Proper way to handle checkpoints on instagrapi-rest #30

Open Stiveknx opened 2 years ago

Stiveknx commented 2 years ago

While using instagrapi-rest, is useless to use the default behavior for instagrapi, to ask the SMS / E-mail code on input (STDIN). https://github.com/adw0rd/instagrapi/blob/092b19713f920e13641c45899be5f3afab827cf4/instagrapi/mixins/private.py#L33

Since we run on an server, which is probably runing on a background task, there's no interaction with it.

A simple fork would be just setting a new challenge_code_handler https://github.com/Stiveknx/instagrapi-rest/commit/90a2b23f0a31ae988df474876653179176802555#diff-edcfd80d7c5e51c05a01f8fc4079088fe44e05a58382b801009203aca3c8ff3dR27

But, it should be possible to "resume" the previous one challenge. The "resume", would just send a post to challenge url with the code. It could be an endpoint, like this one: https://github.com/Stiveknx/instagrapi-rest/commit/90a2b23f0a31ae988df474876653179176802555#diff-edcfd80d7c5e51c05a01f8fc4079088fe44e05a58382b801009203aca3c8ff3dR65

But, I didn't find out, how to resume an Checkpoint, or specifically, how to "save" previous checkpoint data and resume it after.

Any clues?

Jmallone commented 2 years ago

Hi @Stiveknx i have the same problem

I made a twitter post asking for help, in which I summarized the main problem and the main answer was to perform a pooling the post: https://twitter.com/jmallone2/status/1496613584385810439

but I'm thinking to create a thread when I call this /auth/login and return for frontend my PID thread and the msg for handle and the user type a code and in another endpoint this verification code is sending e.g "POST /verify-email/PID_THREAD/VERIFICATION_CODE_HERE"

and this another endpoint catch de PID_THREAD and put the VERIFICATION_CODE in thread stdin directly

reach me if you will want talk more :+1:

Stiveknx commented 2 years ago

Called you on WhatsApp.

I believe we have an better way to handle it, I've been working here, the solution is almost done, just require some more tests.

Jmallone commented 2 years ago

A palliative solution for this issue:

instagrapi-rest: https://github.com/Jmallone/instagrapi-rest-1/commit/7d191de8b151aecc021a134fbdf8fe7e3101c5c1

instagrapi: https://github.com/Jmallone/instagrapi-1/commit/827750dc5270e345b2645ce5b3b1e4eb98807548 https://github.com/Jmallone/instagrapi-1/commit/54712c582ae21027d2f9311980177cfe07603a4c https://github.com/Jmallone/instagrapi-1/commit/cdef5f111cc14c5fdbc09436a032af79780cac2c

https://user-images.githubusercontent.com/6977257/158617160-542e775b-885c-4325-9911-cc7a0a23e4ce.mp4