Jesus / dropbox_api

Ruby client library for Dropbox API v2
MIT License
171 stars 113 forks source link

Implements #81 Refresh tokens support #83

Closed tomekdrazek closed 3 years ago

tomekdrazek commented 3 years ago

This change implements use of dynamic tokens, that refresh automatically after they expire with the simplified procedure (without user interaction needed). The details how to do that are described in dedicated section of README.md.

kir commented 3 years ago

Are there any plans to merge/release this? Dropbox is going to enforce refresh tokens in September for new connections, as far as I understand.

on September 30th, 2021, the Dropbox OAuth flow will no longer return new long-lived access tokens.

kmuto commented 3 years ago

I tried this patch and it worked. I got application code URL and first token, then succeeded refresh with stored token after first token was expired. README insturction was bit difficult for me, but it may be my poor understanding of OAuth.

massongit commented 3 years ago

README insturction was bit difficult for me

I think so, too. I think it will be easier to understand if there is a simple sample program about refresh tokens.

fpsvogel commented 3 years ago

Thank you for this! When I incorporated the patch into my app, I made one small change to include the callback URL.

In the Rails setup guide you have auth_bearer = authenticator.get_token(params[:code], :redirect_uri => redirect_uri), so in DropboxApi::Token I tweaked it to work the same way:

def self.from_code(authenticator, code, redirect_uri: nil)
  self.new(authenticator, authenticator.auth_code.get_token(code, redirect_uri: redirect_uri))
end

This way I can specify my callback URL, as I was doing before. I'm not sure if you want to include this option (or if this is the best way to do it) but I wanted to let you know anyway.

apurvis commented 3 years ago

also here to see if this will be merged soon...

erikyuzwa commented 3 years ago

likewise 🙇

Jesus commented 3 years ago

I'm hoping to find the time to merge this before Sept 30th. 🤞

christiangenco commented 3 years ago

Uhhh hey please merge this 😅

Jesus commented 3 years ago

@tomekdrazek thank you so much for your contribution, I used your approach as a starting point for #88 which is now merged.