]> git.nbdom.net Git - nb.git/commitdiff
ovh-api
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 30 Mar 2016 14:19:50 +0000 (16:19 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 30 Mar 2016 14:19:50 +0000 (16:19 +0200)
bin/ovh-api

index eade10a90b3e539b2d47cc46d93f1240b78fbe8d..1a2a31bcb1e7fa074245f23b2e4ae0794677a62e 100755 (executable)
@@ -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