in reply to Dropbox problem
I assume you deleted the value of $access_token from your post for security reasons (reasonable). But assuming there is a token value there, you seem to be passing the token into the key for the $dropbox object. But the SYNOPSIS shows you need to pass in a key and a secret , and then you should do $dropbox->access_token($access_token); if you have a token already. You aren't following that pattern. Do you have a reason for not following that pattern? (Maybe there's some other example I haven't found in the docs that show passing the token into the key attribute, but I cannot find such on the main page of the documentation).
thus, my guess as to what you really want:
#!/usr/bin/perl use lib '.'; use strict; use warnings; use WebService::Dropbox; use IO::File; my $filename = '/var/www/vhosts/path/httpdocs/path/file.txt'; my $access_token = ''; # TOKEN goes here my $key = ''; # APPLICATION KEY goes here my $secret = ''; # APPLICATION SECRET goes here my $dropbox = WebService::Dropbox->new({ key => $key, # this should be KEY, not TOKEN secret => $secret, # this should be SECRET, not skipped # oauth2 is true by default for recent versions }); $dropbox->access_token($access_token); # must send dropbox the access +token AFTER the key/secret was defined when object was instantiated my $local_file = $filename; my $remote_path = '/Uploads/$filename'; my $content = IO::File->new($local_file, '<') or die "Cannot open $loc +al_file: $!"; my $result = $dropbox->upload($remote_path, $content); if ($result) { print "Successfully uploaded $local_file to Dropbox as $remote_pat +h\n"; } else { die "Upload failed: " . $dropbox->error; }
Untested, since I don't have dropbox developer credentials. But this would be the next thing I tried, if I were you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dropbox problem
by frank1 (Monk) on Dec 24, 2025 at 17:01 UTC |