Im working on a larger project that will use this feature of making a Instagram account. So far i get the server to understand my reqeust though it wont make a account. I assume im missing some info in the request but im not sure.
def main(): username = "" password = "" email_to_use = "" first_name = "" time = str(int(datetime.datetime.now().timestamp())) enc_password = f"#PWD_INSTAGRAM_BROWSER:0:{time}:{password}" session = requests.Session() # set a cookie that signals Instagram the "Accept cookie" banner was closed session.cookies.set("ig_cb", "2") session.headers.update({'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36'}) session.headers.update({'Referer': 'https://www.instagram.com'}) res = session.get('https://www.instagram.com') csrftoken = None for key in res.cookies.keys(): if key == 'csrftoken': csrftoken = session.cookies['csrftoken'] session.headers.update({'X-CSRFToken': csrftoken}) login_data = {'username': username, 'enc_password': enc_password, 'email': email_to_use, 'first_name': first_name,} login = session.post('https://www.instagram.com/accounts/web_create_ajax/attempt/', data=login_data, allow_redirects=True) session.headers.update({'X-CSRFToken': login.cookies['csrftoken']}) cookies = login.cookies print(login.text)
that code returns
{"account_created":false,"dryrun_passed":true,"username_suggestions":["jsonhews","floristry_zrpc","jsonhews2","jsonhews43","jsonhews524","jsonhews3154","jsonhews7","jsonhews64","jsonhews356","jsonhews2146","jsonhews3"],"status":"ok"}
Not sure what i could do so if you have any ideas id love to hear! Thanks.