diezo / Ensta

🔥 Fast & Reliable Python Package For Instagram API - 2024
https://bit.ly/ensta-discord
MIT License
371 stars 44 forks source link

Support login persistence #111

Closed claell closed 6 months ago

claell commented 6 months ago

Persisting login information might be a good idea. Otherwise, the account appears to be signed in from scratch for every new creation of the Mobile() class, right?

diezo commented 6 months ago

That's not the case. Ensta auto-saves login sessions inside ensta-sessions directory by default while using the Mobile class. Whenever you create a new instance of Mobile(), it'll load the saved session rather than creating a new one until the saved session expires.

claell commented 6 months ago

Ah, perfect, then I wasn't familiar with the details.

Is there a way to control this? For example, only one time giving explicit credentials, and then just normally instantiating without credentials until the session expired?

diezo commented 6 months ago

Mobile class will calculate the hash of username and password and find it's corresponding session file. Then, it'll use that session until it expires. The credentials will only be used to verify the saved session files and will be used to create new sessions when the existing ones expire.

diezo commented 6 months ago

If you don't wish to explicitly provide your credentials and rather use a saved session, you can do so by passing the contents of the session file as a string to Mobile class's session_data parameter. Hope that helps.