From 65f86d72726573d8581d7fb499759e80f039b5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kadir=20Tar=C4=B1k=20=C4=B0lgin?= <84983622+kticoder@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:37:22 +0300 Subject: [PATCH] Update account.py The password change feature was missing. So I added it :) --- instagrapi/mixins/account.py | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/instagrapi/mixins/account.py b/instagrapi/mixins/account.py index 73799c7b..e34dacbd 100644 --- a/instagrapi/mixins/account.py +++ b/instagrapi/mixins/account.py @@ -57,7 +57,46 @@ def account_info(self) -> Account: """ result = self.private_request("accounts/current_user/?edit=true") return extract_account(result["user"]) + + def change_password( + self, + old_password: str, + new_password: str, + ) -> bool: + """ + Change password + + Parameters + ---------- + new_password: str + New password + old_password: str + Old password + Returns + ------- + bool + A boolean value + """ + try: + enc_old_password = self.password_encrypt(old_password) + enc_new_password = self.password_encrypt(new_password) + data = { + "enc_old_password": enc_old_password, + "enc_new_password1": enc_new_password, + "enc_new_password2": enc_new_password, + } + self.with_action_data( + { + "_uid": self.user_id, + "_uuid": self.uuid, + "_csrftoken": self.token, + } + ) + result = self.private_request("accounts/change_password/", data=data) + return result + except Exception as e: + return False def set_external_url(self, external_url) -> dict: """ Set new biography