Giter Site home page Giter Site logo

Comments (5)

ipwnponies avatar ipwnponies commented on June 13, 2024 1

If we need to store the user's credentials to relogin, we can store in the OS keystore using keyring package. Seems like this is the correct approach that avoids rolling our own solution.

from mealpy.

ipwnponies avatar ipwnponies commented on June 13, 2024

The session cookie has a TTL of 24 hours. This feature would be useful for reinvoking adhoc.

But as a scheduled task, the current logic of login every time scheduler goes off (to get fresh session cookie) would be necessary

Edit: But how does a browser keep indefinitely logged in? Maybe stale session in cookie still works to get a refreshed one, we're set. If not, we can try periodically querying site to keep session alive.

from mealpy.

ipwnponies avatar ipwnponies commented on June 13, 2024

From #16 (comment), a possible different solution for this issue:

There are three cookies returned on login: __cfduid, tt_visitor_id and _mealpal_session. The first two expire in 2020 (exactly 1 year from now), and the last one doesn't have an expiry. Whichever it is, it looks like we won't have to worry about cookies expiring. You can inspect MealPal(...).cookies after login to check the cookies, or use Chrome Dev tools.

We might be able to persist the cookie, in place of credentials. If we store it in config.yaml or keyring, this will persist for a year, for both adhoc runs and scheduled batch.

from mealpy.

edmundmok avatar edmundmok commented on June 13, 2024

The cookies are all contained in .cookies of a MealPal object after .login is successful, which is of type requests.cookies.RequestsCookieJar. Not too sure about the security aspect of this but we can just pickle the cookie jar object to be stored as a binary file locally, and unpickle it again when we need it. With this, I don't think we will need keyring anymore?

from mealpy.

ipwnponies avatar ipwnponies commented on June 13, 2024

I agree, with persisted cookies we can avoid using keyring altogether.

It looks to be FileCookieJar, from stdlib, is passed to the requests session and that is has support for serializing to disk.

from mealpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.