Skip to content

Instaloader get_comments() function is returning 403 forbidden error with message login required #2480

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

Closed
Adharshcs opened this issue Jan 14, 2025 · 8 comments
Labels
question Question stale Issue is inactive for a long time

Comments

@Adharshcs
Copy link

I am trying to get the comments of a post using instaloader. but it returns 403 forbidden with message login required

`
loader = instaloader.Instaloader()
try:
loader.load_session_from_file(username)

except Exception as e:
print(f"Failed to log in: {e}")

post = instaloader.Post.from_shortcode(loader.context, "DCH2uvnzgma")
if (loader.context.is_logged_in):
print("Logged in")
for comment in post.get_comments():
print(f"{comment.owner.username}: {comment.text}")

JSON Query to api/v1/media/3497004342417688986/comments/: 403 Forbidden - "fail" status, message "login_required" when accessing https://i.instagram.com/api/v1/media/3497004342417688986/comments/?can_support_threading=true&permalink_enabled=false

@Adharshcs Adharshcs added the question Question label Jan 14, 2025
@m4l0n
Copy link

m4l0n commented Jan 22, 2025

Bump, facing the same issue.

@kartikxisk
Copy link

same here

@kartikxisk
Copy link

anyone know how to get rid of this

@nfach98
Copy link

nfach98 commented Jan 31, 2025

I tried to log in using session and it worked

Loader.load_session("", {
"csrftoken": "",
"sessionid": "",
"ds_user_id": "",
"mid": "",
"ig_did": ""
})

@vipseixas
Copy link

It seems to work when using cookies instead of an explicit login

Copy link

There has been no activity on this question for an extended period of time. This issue will be closed after further 14 days of inactivity.

@github-actions github-actions bot added the stale Issue is inactive for a long time label Feb 23, 2025
@Adharshcs
Copy link
Author

I tried to log in using session and it worked

Loader.load_session("", {
"csrftoken": "",
"sessionid": "",
"ds_user_id": "",
"mid": "",
"ig_did": ""
})

Yep Worked. Thanks

@Adharshcs
Copy link
Author

It seems to work when using cookies instead of an explicit login

Yeah. But no idea why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question stale Issue is inactive for a long time
Projects
None yet
Development

No branches or pull requests

5 participants