pve-apiclient/examples/example3.pl
Fabian Grünbichler 7b6f8f1d17 implement api token support
and add an example for it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-02-05 11:17:18 +01:00

25 lines
517 B
Perl
Executable File

#!/usr/bin/perl
# NOTE: you need to set the API token and PVE host below for this to work
use strict;
use warnings;
use PVE::APIClient::LWP;
use JSON;
my $apitoken = 'PVEAPIToken=USER@REALM!TOKENID=TOKENVALUE';
my $hostname = "127.0.0.1";
my $conn = PVE::APIClient::LWP->new(
apitoken => $apitoken,
host => $hostname,
# allow manual fingerprint verification
manual_verification => 1,
);
my $res = $conn->get("/access/permissions", {});
print to_json($res, { pretty => 1, canonical => 1});