Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial InstagramBridge private feed - Include CSRF #1894

Closed
wants to merge 2 commits into from

Conversation

Fmstrat
Copy link

@Fmstrat Fmstrat commented Dec 12, 2020

[HOLD PR]
A bit more research needs to be done to store the full cookie data. Since the urlgen cookie variable is tied to IP, this is not as straight forward as first appeared. The 429 block may have expired during my testing causing false positives with the CSRF token

Purpose
While integration with the new configuration PR (#1343) is required, this takes the first steps to enabling private feeds in the Instagram Bridge.

Caveats
I cannot fully validate this without wider user testing for 429 errors, however in my brief testing it has worked well.

Usage
Until the above integration occurs, users will need to edit the CSRF_TOKEN variable (see here) to match a token they get from Instagram. To get a token, users can view any page on Instagram while logged in and look at the network inspector for any call to a /graphql URL:

CSRF

@danganhhop
Copy link

@em92 em92 marked this pull request as draft December 13, 2020 11:02
@em92
Copy link
Contributor

em92 commented Dec 13, 2020

[HOLD PR]

It is possible to mark any PR as draft, to deny merging it accidentally.

@JimDog546
Copy link
Contributor

I've been experimenting with this and I still am so I'm not sure if I've found a good solution or how long it will last, but it at least seems to be working. Surprisingly providing the CSRF token doesn't seem to do anything. The only thing that seems to work, at least for me, is the sessionid cookie.

Similar to what you've done, I added a constant with my sessionid near the top, added this within getInstagramJSON:

$header = array('cookie: sessionid=' . self::SESSIONID);

and added $header to the getContents function call:

$data = getContents(self::URI .
                                'graphql/query/?query_hash=' .
                                self::USER_QUERY_HASH .
                                '&variables={"id"%3A"' .
                                $userId .
                                '"%2C"first"%3A10}',$header);

I'm not sure how this affects 429 errors but it at least allows me to view profiles I follow that are not public so it appears to be doing so using my credentials as if I've logged in.

@em92
Copy link
Contributor

em92 commented Apr 8, 2021

Hi, @JimDog546 ! Is your solution with session id is still working?

@em92
Copy link
Contributor

em92 commented Apr 8, 2021

I mean do you meet 429 errors on your private RSS-Bridge instance?

@JimDog546
Copy link
Contributor

JimDog546 commented Apr 8, 2021

@em92 Yes, the session id is still working for me. No more 429 errors, but I did run into one similar issue that I've worked around with caching.

My feed reader (Inoreader) doesn't allow me to specify the update interval and I'm using it against 300+ profiles. After a few days of its very frequent queries, Instagram sent me an e-mail saying they thought my account was compromised and they eventually temporarily blocked my IP address. I shut everything down for a few days to let that clear up and experimented with caching to try to cut down on the amount of requests that actually get sent to Instagram. Surprisingly I was able to make things work simply by adding a CACHE_TIMEOUT to InstagramBridge.php:

const CACHE_TIMEOUT = 43200; // 12 hours

12 hours works for me and my needs so I haven't experimented with any lower values for more frequent updates. I've been running this way (with the session ID cookie and CACHE_TIMEOUT) for at least a month with no issues.

@em92
Copy link
Contributor

em92 commented Apr 11, 2021

Thanks for the report @JimDog546!
I've just added my personal session id with increased cache timeout patch to my public RSS-Bridge instance. Approx 200 profiles, so it should be fine.

@dvikan
Copy link
Contributor

dvikan commented Mar 29, 2022

@Fmstrat Any progress here? We need a maintainer for the Instagram bridge. Can you step up?

@dvikan dvikan closed this May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants