The error#
LoginRequiredException is a subclass of InstaloaderException. These are the messages in 4.16:
Redirected to login page. Use --login or --load-cookies.
Login required.
Login required to access comments of a post.
Login required to access likes of a post.
Login required to get a profile's followers.
Login required to get a profile's followees.A private profile's posts use this form:
Login required to access the posts of private profile {username}.If the session was already logged in and Instagram still redirects to the login page, instaloader raises AbortDownloadException instead:
Redirected to login page. You've been logged out, please wait some time, recreate the session and try againWhat triggers it#
get_json follows redirects. If the Location header starts with https://www.instagram.com/accounts/login or https://i.instagram.com/accounts/login, and is_logged_in is false, it raises LoginRequiredException with the --login message.
The same exception is raised for comments, likes, followers, followees, saved posts and the iPhone endpoints when there is no session. The CLI flag named in the message is --login or --load-cookies.
How to confirm#
Catch instaloader.exceptions.LoginRequiredException and print str(e). Match it to the lines above. A redirect message means the response went to the login URL. A Login required to ... message means that method checks is_logged_in first.
Fixes#
Log in with the flags the message names, --login or --load-cookies, and reuse the session file. That still uses your Instagram account from the machine that runs the script. Instagram can log that session out. The logged-out path then hits this exception again.
Do not treat a private profile as public by retrying the same anonymous call. The posts line names the username.
SocialScrape#
Instagram profile is GET /v1/instagram/profile. A private account comes back with is_private true. Posts are GET /v1/instagram/profile/posts, and one post is GET /v1/instagram/post.
Failed requests cost 0 credits. New accounts get 100 credits on signup, no card. Codes are on errors.