Coder Social home page Coder Social logo

Error refreshing token about spotify.py HOT 5 CLOSED

mental32 avatar mental32 commented on July 23, 2024
Error refreshing token

from spotify.py.

Comments (5)

mental32 avatar mental32 commented on July 23, 2024

Damn nice catch, yeah if you can submit a pr I can merge it immediately.

I don't have access to my machine atm so I won't be able to fix this for a couple of hours

from spotify.py.

mental32 avatar mental32 commented on July 23, 2024

Keep in mind, If I merge, the changes will still have to wait until I can release them to pypi

from spotify.py.

micahdlamb avatar micahdlamb commented on July 23, 2024

Great, I'll take a stab at a pull request. I've never done one before. It will probably take me a day or two.

I was also thinking about the way you are implementing this... If I had lots of users connect to my app then I believe this would keep refreshing all their tokens indefinitely. Is there a way to stop the refreshing if I'm done with the user? I was thinking another way this could be done is to detect when an api call fails and do the refreshing then. I'm curious how other oauth applications handle this.

from spotify.py.

mental32 avatar mental32 commented on July 23, 2024

User objects have a refresh attribute that is a read only reference to the task handling the session refreshing, you can stop refreshing a user's token by cancelling the task with User.refresh.cancel()

Currently there is no mechanism in place to deal with a refresh task failing part way, I'd recommend just creating a new user oauth http session and discarding the old user object in this case.

I haven't looked into how other apps handle this situation but if you can find alternatives I'm happy to consider them :)

from spotify.py.

micahdlamb avatar micahdlamb commented on July 23, 2024

Oh awesome, I didn't realize user.refresh was an _asyncio.Task and I can call cancel on it. In any case I think its a mistake for me to be holding onto the User objects for so long. I'm gonna think about it more next weekend.

from spotify.py.

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.