Comments (9)
Feel free to start, I highly appreciate a PR for this 👍
from flysystem-dropbox.
@freekmurze What would be the general approach/preference regarding where/how to store the new refresh tokens? Database? Local file?
from flysystem-dropbox.
Maybe make an interface so users can choose where to store stuff.
from flysystem-dropbox.
In my Laravel setup, I think I will work toward a local storage solution for the refresh token. I am using the CachedAdapter already so I could take an approach of an .env variable with the path.
DropboxServiceProvider.php
namespace App\Providers;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use Spatie\Dropbox\Client as DropboxClient;
use League\Flysystem\Filesystem;
use Spatie\FlysystemDropbox\DropboxAdapter;
use League\Flysystem\Adapter\Local as CacheFilePath;
use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Cached\Storage\Adapter as CustomAdapter;
class DropboxServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Storage::extend('dropbox', function ($app, $config) {
$client = new DropboxClient($config['authorization_token']);
$dropbox = new DropboxAdapter($client);
$local = new CacheFilePath('/mnt/secure_files/dropbox');
$cache = new CustomAdapter($local, 'cachefile', 300);
$adapter = new CachedAdapter($dropbox, $cache);
return new Filesystem($adapter, ['case_sensitive' => false]);
});
}
}
My server is not publicly accessible, and I would be using the offline (long-lived) refresh token. I just went through rclone's process for the same thing on a Debian server.
I'm thinking I could follow the approach rclone took and create a Console configuration script which would allow (as in my case on a server with no public access) a URL to be copied, and taken to a device with internet access to get the initial response code. Then the code gets entered, and first refresh token gets stored.
With that, and adding in logic to incorporate the refresh token process, and adding a catch for the 401 Unauthorized response (which would then require the user to run configuration again), I think that might work. In Client.php where there is a check for the $accessTokenOrAppCredentials
I could incorporate a check for whether the REFRESH_TOKEN_PATH
is empty. If it's not, then proceed with using that.
How does this sound?
from flysystem-dropbox.
I see there is a discussion in dropbox-api which handles credentials. Sorry this was the wrong place.
from flysystem-dropbox.
@garrettboone Hi, did you manage to add short-lived token functionality? Thanks
from flysystem-dropbox.
@anderea1 No, I've been putting it off so my files are piling up in a temp folder. It seems everyone else is going for a end-user interface with oauth2 but I don't need that. If you think you want to do it, go for it. But if not, let me know. I need it myself and should do something soon.
from flysystem-dropbox.
@garrettboone see here if it suits you #86
from flysystem-dropbox.
@anderea1 With long-lived refresh tokens, even though they are long-lived they are part of each response and can be replaced. ie long-lived but short-used. By storing it locally and replacing each request rather than noting in the env, as long as a request is made frequently enough, you won't run into an expired refresh token.
from flysystem-dropbox.
Related Issues (20)
- Call to undefined method League\Flysystem\Filesystem::getTemporaryLink HOT 4
- Download-Progress
- get link HOT 1
- Empty array when show files within a path HOT 5
- use token per User HOT 1
- Retriving files/directories from nested path results in empty array. HOT 1
- Problem while using appKey and appSecret for creating client. HOT 1
- Endless Loop for listContents
- Add compatibility with flysystem v2 HOT 3
- "Client error: `POST https://api.dropboxapi.com/2/files/list_folder` resulted in a `401 Unauthorized
- Unable to install on Laravel 8.35.1 - requirements could not be resolved to an installable set of packages HOT 5
- File download with Dropbox ID HOT 1
- Updated to Laravel 9: Argument #1 ($disk) must be of type ?Illuminate\Contracts\Filesystem\Filesystem, League\Flysystem\Filesystem given, HOT 2
- too many requests when uploading backup file HOT 1
- Access token expiration HOT 9
- Add compatibility for Flysystem 3 HOT 1
- Checking for file or directory HOT 1
- Dropbox Refresh token needed - Long Lived Access Tokens Depecrated HOT 2
- Dropbox Refresh token needed - Long Lived Access Tokens Depecrated HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flysystem-dropbox.