guilhermesad / rspotify

A ruby wrapper for the Spotify Web API
MIT License
717 stars 290 forks source link

More elegant handling of refresh of the access token #195

Closed patrickmryan closed 3 years ago

patrickmryan commented 5 years ago

Added new functionality to the User class to enable more elegant handling of refresh of the access token. The User class now has the option to store a Proc in @@users_credentials[user_id]['access_refresh_callback']. The Proc must accept two parameters. If the access token is refreshed, them the Proc will be called. The new token and the lifetime (in seconds) of the token will be passed as arguments.

patrickmryan commented 5 years ago

Thanks. I'll make those updates and send a new PR. Do you know why the CI is failing? I haven't used Jenkins before so I can't figure out what's going on.

pat

On Tue, Aug 20, 2019 at 8:05 PM Guilherme Sad notifications@github.com wrote:

@guilhermesad requested changes on this pull request.

In README.md https://github.com/guilhermesad/rspotify/pull/195#discussion_r315953136:


 RSpotify.raw_response = true

 RSpotify::Artist.search('Cher') #=> (String with raw json response)

+Alternately, you can store a proc that is invoked when a new access token is generated. This give you the

PR looks great, thx! Some notes:

• I think this should be Additionally, you can use a proc..., instead of Alternately, you can store a proc.... Since it's not actually an alternative to refresh the token, but a way for you to do something with the access token and its lifetime additionally if you want. The PR also gives the idea this is a new way to refresh the token.

• Looks like you mixed 2 sections of the README, the refreshing token part and the raw response one.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/guilhermesad/rspotify/pull/195?email_source=notifications&email_token=ADEHXMHRZBSHCLLS5URK6GLQFSBFJA5CNFSM4IF3RVU2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCCFFMDQ#pullrequestreview-277501454, or mute the thread https://github.com/notifications/unsubscribe-auth/ADEHXMCM6FNIFPEBFHBLQ4DQFSBFJANCNFSM4IF3RVUQ .

-- imageryan@gmail.com pmryan@acm.org https://www.facebook.com/patrick.m.ryan1 http://www.imageryan.com

lukel97 commented 3 years ago

Hi, is there any update on this?

guilhermesad commented 3 years ago

Looks good, thanks!