Nuvol::Connector - Base class for Nuvol connectors
use Nuvol; my $configfile = '/path/to/configfile'; # existing config file my $connector = Nuvol::connect($configfile); # new or existing config file my $connector = Nuvol::autoconnect($configfile); # with additional parameters use Nuvol::Connector; my $connector = Nuvol::Connector->new($configfile, $service, $params); $connector->authenticate; $connector->authenticated; $connector->config; $connector->configfile; $connector->disconnect; $connector->drive; $connector->drives; $connector->update_drives; $connector->url;
Nuvol::Connector is the base class for Nuvol connectors.
use Nuvol; $configfile = '/path/to/configfile'; $connector = Nuvol::connect($configfile); # existing config file $connector = Nuvol::autoconnect($configfile); # new or existing config file
Connections are opened with Nuvol::connect or Nuvol::autoconnect.
$connector = Nuvol::Connector->new($configfile, $service);
To create a new file, the parameter $service is required. It defines the type of service that will be activated in all objects created with this connector. Available services are Dropbox, Office365, and Dummy
$service
%params = ( app_id => $app_id, redirect_uri => $redirect_uri, scope => $scope, ); $connector = Nuvol::Connector->new($configfile, $service, \%params);
Optional parameters can be used to define app_id, redirect_uri, scope. Notice that the final value for the scope is set during authentication.
app_id
redirect_uri
scope
$connector = Nuvol::Connector->new($configfile);
If the config file exists all values are read from it and additional parameters are ignored.
$ perl -MNuvol::Connector -E'Nuvol::Connector->new("~/.office365.conf", "Office365")->authenticate'
New config files can be created and authenticated in the console.
Nuvol::Connector inherits the following methods from Nuvol::Role::Metadata:
$connector->authenticate;
Starts an interactive authentication process. It will display a URL that has to be opened in a browser to start the authorization flow. The resulting URL is copied back to the console where it is used to retrieve the access tokens. If this process succeeds, the information is written to the config file. From now on it is possible to open the connector directly with Nuvol::connect.
%params = ( access_token => $access_token, expires_in => $seconds, refresh_token => $refresh_token, scope => $scope, ); $connector = $connector->authenticated(\%params);
Setter for new authentication tokens. Can be used if the authentication is made in an external module.
$value = $connector->config;
Getter for the config. Returns a Nuvol::Config.
$value = $connector->configfile;
Getter for the path to the configfile.
$connector = $connector->disconnect($newvalue);
Deletes the confidential information (access token, refresh token and valitidy time) from the config file. On some services it invalidates the tokens on the server side, so it is always more secure to use this method instead of just deleting the file.
To use a disconnected config file again it has to be re-authenticated with "authenticate".
$drive = $connector->drive($path);
Getter for a drive with the specified path. Returns a Nuvol::Drive.
path
$drive = $connector->drive; $drive = $connector->drive('~');
Called with no parameter or with ~ as path will return the default drive.
~
$drives = $connector->list_drives; $default_drive = $connector->list_drives->first;
Lists the available drives. Returns a Mojo::Collection containing one or more Nuvol::Drive with the default drive at the first position. This list may be incomplete.
Nuvol, Nuvol::Config, Nuvol::Drive, Nuvol::Role::Metadata.
To install Nuvol, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nuvol
CPAN shell
perl -MCPAN -e shell install Nuvol
For more information on module installation, please visit the detailed CPAN module installation guide.