When creating a Client object with stored cookies, I am able to successfully login using Client.login but after, when trying to call hashtag_medias_top or media_likers, both raise a login_required exception.
Sometimes it will allow me to access the top media posts but after that media_likers will return a login_required exception
To Reproduce
Create Client object with stored cookies in the settings dictionary which is passed as a parameter
Example of cookies dictionary passed in to Client settings:
I have replaced the cookie values with '...' to not leak data
{'ig_did': '...', 'ig_nrcb': '1', 'csrftoken': '...', 'ds_user_id': '...', 'sessionid': '...', 'rur': '...', 'shbid': '...', 'shbts': '...', 'Authorization': 'Bearer IGT:...', 'IG-U-DS-USER-ID': '..., 'IG-U-RUR': 'NCG', 'IG-INTENDED-USER-ID': '...', 'X-IG-WWW-Claim': '...'}
Log in to account with username and password
call hashtag_medias_top with client
Traceback
`Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 128, in _send_public_request
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.instagram.com/explore/locations/39602068/?__a=1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 171, in location_info
location = self.location_info_a1(location_pk)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 132, in location_info_a1
data = self.public_a1_request(f"/explore/locations/{location_pk}/") or {}
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 173, in public_a1_request
response = self.public_request(
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 89, in public_request
raise e
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 72, in public_request
return self._send_public_request(url, **kwargs)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 161, in _send_public_request
raise ClientError(e, response=e.response)
instagrapi.exceptions.ClientError: 500 Server Error: Internal Server Error for url: https://www.instagram.com/explore/locations/39602068/?__a=1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 298, in _send_private_request
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/locations/39602068/location_info/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 360, in hashtag_medias_top
medias = self.hashtag_medias_top_a1(name, amount)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 323, in hashtag_medias_top_a1
return self.hashtag_medias_a1(name, amount, tab_key="edge_hashtag_to_top_posts")
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 220, in hashtag_mediasa1
medias, = self.hashtag_medias_a1_chunk(name, amount, tab_key)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 184, in hashtag_medias_a1_chunk
medias.append(self.media_info_gql(media_pk))
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/media.py", line 209, in media_info_gql
data["shortcode_media"]["location"] = self.location_complete(
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 68, in location_complete
info = self.location_info(location.pk)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 177, in location_info
location = self.location_info_v1(location_pk)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 153, in location_info_v1
result = self.private_request(f"locations/{location_pk}/location_info/")
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 445, in private_request
raise e
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 432, in private_request
self._send_private_request(endpoint, kwargs)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 323, in _send_private_request
raise LoginRequired(response=e.response, last_json)
instagrapi.exceptions.LoginRequired: login_required
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 298, in _send_private_request
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/tags/nft/sections/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/application.py", line 356, in get_top_posts
posts = self._bot.get_top_hashtag_posts(hashtag, num_posts)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/Bot.py", line 118, in get_top_hashtag_posts
return self._cl.hashtag_medias_top(hashtag, num_posts)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 362, in hashtag_medias_top
medias = self.hashtag_medias_top_v1(name, amount)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 341, in hashtag_medias_top_v1
return self.hashtag_medias_v1(name, amount, tab_key="top")
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 302, in hashtag_mediasv1
medias, = self.hashtag_medias_v1_chunk(name, amount, tab_key)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 259, in hashtag_medias_v1_chunk
result = self.private_request(
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 445, in private_request
raise e
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 432, in private_request
self._send_private_request(endpoint, kwargs)
File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 323, in _send_private_request
raise LoginRequired(response=e.response, last_json)
instagrapi.exceptions.LoginRequired: login_required`
Expected behavior
Able to get top posts for a hashtag without returning login_required exception after being able to successfully log in to account
Desktop (please complete the following information):
OS: Pop!_OS 21.10
Python version: 3.9.7
instagrapi version: 1.16.14
Additional context
Add any other context about the problem here.
Describe the bug
Sometimes it will allow me to access the top media posts but after that media_likers will return a login_required exception
To Reproduce
Example of cookies dictionary passed in to Client settings:
{'ig_did': '...', 'ig_nrcb': '1', 'csrftoken': '...', 'ds_user_id': '...', 'sessionid': '...', 'rur': '...', 'shbid': '...', 'shbts': '...', 'Authorization': 'Bearer IGT:...', 'IG-U-DS-USER-ID': '..., 'IG-U-RUR': 'NCG', 'IG-INTENDED-USER-ID': '...', 'X-IG-WWW-Claim': '...'}
Traceback `Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 128, in _send_public_request response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.instagram.com/explore/locations/39602068/?__a=1
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 171, in location_info location = self.location_info_a1(location_pk) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 132, in location_info_a1 data = self.public_a1_request(f"/explore/locations/{location_pk}/") or {} File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 173, in public_a1_request response = self.public_request( File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 89, in public_request raise e File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 72, in public_request return self._send_public_request(url, **kwargs) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/public.py", line 161, in _send_public_request raise ClientError(e, response=e.response) instagrapi.exceptions.ClientError: 500 Server Error: Internal Server Error for url: https://www.instagram.com/explore/locations/39602068/?__a=1
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 298, in _send_private_request response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/locations/39602068/location_info/
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 360, in hashtag_medias_top medias = self.hashtag_medias_top_a1(name, amount) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 323, in hashtag_medias_top_a1 return self.hashtag_medias_a1(name, amount, tab_key="edge_hashtag_to_top_posts") File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 220, in hashtag_mediasa1 medias, = self.hashtag_medias_a1_chunk(name, amount, tab_key) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 184, in hashtag_medias_a1_chunk medias.append(self.media_info_gql(media_pk)) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/media.py", line 209, in media_info_gql data["shortcode_media"]["location"] = self.location_complete( File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 68, in location_complete info = self.location_info(location.pk) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 177, in location_info location = self.location_info_v1(location_pk) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/location.py", line 153, in location_info_v1 result = self.private_request(f"locations/{location_pk}/location_info/") File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 445, in private_request raise e File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 432, in private_request self._send_private_request(endpoint, kwargs) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 323, in _send_private_request raise LoginRequired(response=e.response, last_json) instagrapi.exceptions.LoginRequired: login_required
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 298, in _send_private_request response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/tags/nft/sections/
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/application.py", line 356, in get_top_posts posts = self._bot.get_top_hashtag_posts(hashtag, num_posts) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/Bot.py", line 118, in get_top_hashtag_posts return self._cl.hashtag_medias_top(hashtag, num_posts) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 362, in hashtag_medias_top medias = self.hashtag_medias_top_v1(name, amount) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 341, in hashtag_medias_top_v1 return self.hashtag_medias_v1(name, amount, tab_key="top") File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 302, in hashtag_mediasv1 medias, = self.hashtag_medias_v1_chunk(name, amount, tab_key) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/hashtag.py", line 259, in hashtag_medias_v1_chunk result = self.private_request( File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 445, in private_request raise e File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 432, in private_request self._send_private_request(endpoint, kwargs) File "/home/izucked/Desktop/Instagram-Mass-DM-Bot/instagrapi/mixins/private.py", line 323, in _send_private_request raise LoginRequired(response=e.response, last_json) instagrapi.exceptions.LoginRequired: login_required`
Expected behavior
Desktop (please complete the following information):
Additional context Add any other context about the problem here.