mental32 / spotify.py

🌐 API wrapper for Spotify 🎶
https://spotifypy.readthedocs.io/en/latest/
MIT License
150 stars 38 forks source link

Refresh the token when a request fails. #40

Closed micahdlamb closed 4 years ago

micahdlamb commented 4 years ago

Please look over this as I removed a lot of code I don't think is needed anymore without taking much time to understand it.

Am I supposed to make the pull request into master or some other version?

I manually tested the User.from_code, User.from_token, User.from_refresh_token and doing some api calls with each. I waited a couple hours and tried again to make sure the token refreshed.

I ought to run the tests from the tests folder but I'm a bit confused how to do that.

micahdlamb commented 4 years ago

Are those check fails legitimate? One of them is about environment variables not being set.

This error doesn't make sense: spotify/http.py:1715: error: Incompatible types in assignment (expression has type "Dict[str, str]", variable has type "None")

bearer_info is only being set if token is specified:

        if token:
            self.bearer_info = {"access_token": token}

Do you have any suggestions on how to fix the errors?

micahdlamb commented 4 years ago

When I add the environment variables before running the tests then everything works. Why isn't the Travis script adding the environment variables?

mental32 commented 4 years ago

@micahdlamb the travis errors regarding missing environment are a security restriction imposed by travis, I simply forgot to modify the travis config to account for this.

The mypy error can be fixed by annotating self.bearer_info to Optional[Dict[str, str]]

micahdlamb commented 4 years ago

When I did a merge through github it completely broke all the code. When I retried locally in pycharm it all looks good now. Very strange.

mental32 commented 4 years ago

@micahdlamb sorry to drop this on you, but could you attempt to merge PR this into v0.8.2?