ahmdrz / goinsta

Unofficial Instagram API written in Golang
MIT License
895 stars 247 forks source link

Updated endpoints to v2021 and fix for login issues #353

Open Davincible opened 3 years ago

Davincible commented 3 years ago

The code in this repo is based on a 2yo app version, and since then, quite a lot has changed. From the way insta makes the requests, to the endpoints themselves. This has also caused the occasional login issue. I needed an up-to-date insta API in go for a project, so I've updated everything, and made it public in a fork. Everything should fully work again now.

hexakis commented 3 years ago

I was having this problem where I could not login, but a few days later after that I tried again and it just worked my issue was probably unrelated to the change to Instagram's API. Why it continues to work when Instagram has changed their endpoints is behond me I suspect backwards compatability with older version of Instagram running on old phones being the reason,

Davincible commented 3 years ago

@hexakis The reason it stopped and started working is both this lib as well as the official android apk call two endpoints during the login process accounts/get_prefill_candidates/. accounts/contact_point_prefill/, that are very sensitive and often return an HTTP status code 429, too many requests. This also happens with the official app however, but it just ignores it as they are not critical to the login process, this lib however, returns every error it finds, and therefore the whole login process errors out.

As far as why the rest does continue to work, it is due to backward compatibility. Quite a few things have changed, however. The main being that they stepped away from conventional cookies and csrf tokens, and put everything in a bunch of separate headers. The endpoints also changed slightly, some are called with different parameters, and some return a different result now

PhantomX7 commented 3 years ago

@Davincible i got this Failed to fetch initial messages inbox snapshot: json: cannot unmarshal object into Go struct field Item.inbox.threads.last_permanent_item.link of type string panic error when using your fork. is there any way to solve this?

Davincible commented 3 years ago

@PhantomX7 Ah, yeah we can fix that. Some endpoints have changed their data format, and as I haven't seen all possible responses I have not seen all data type mismatches yet. Could you please open an issue on my fork? I'll have a look.

Edit: Nevermind, should be fixed now! Make sure to update the repo with go get -u -v github.com/Davincible/goinsta@latest