From: Nicolas Boisselier Date: Wed, 30 Mar 2016 14:19:50 +0000 (+0200) Subject: ovh-api X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=242efd1f600a9aa66f128b8f196d62ddd742fcca;p=nb.git ovh-api --- diff --git a/bin/ovh-api b/bin/ovh-api index eade10a9..1a2a31bc 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -41,6 +41,14 @@ my @KEY = split(":",shift @ARGV); my $URL = shift @ARGV; my $METHOD = @ARGV ? shift(@ARGV) : 'GET'; +# Auth +if (@KEY==1) { + #print qq|curl -XPOST -H"X-Ovh-Application: $KEY[0]" -H "Content-type: application/json" https://eu.api.ovh.com/1.0/auth/credential -d '{"accessRules": [ { "method": "GET", "path": "/*" } ], "redirection":"https://www.mywebsite.com/" }'\n|; + exec qq|curl -s -XPOST -H"X-Ovh-Application: $KEY[0]" -H "Content-type: application/json" https://eu.api.ovh.com/1.0/auth/credential -d '{"accessRules": [ { "method": "GET", "path": "/*" } ] }'|.'|jq .'; + #exec("curl","-XPOST",'-H',"X-Ovh-Application: $KEY[0]",'-H','Content-type: application/json','https://eu.api.ovh.com/1.0/auth/credential','-d',qq|'{"accessRules": [ { "method": "GET", "path": "/*" } ],"redirection":"https://www.mywebsite.com/" }'|); + exit 0; +} + my $o = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]); my $response = $o->get(path=>$URL,method=>$METHOD); @@ -150,7 +158,7 @@ $NAME - Script to query ovh =head1 SYNOPSIS -Quick usage: $NAME k1:k2:k3 URL +Quick usage: $NAME k1:k2:k3 URL or $NAME k1 to activate a first account =head1 DESCRIPTION