summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-05-20 16:27:00 +0200
committerByron Jones <glob@mozilla.com>2015-05-20 16:27:00 +0200
commit09ff98ad16f9301c36b21fd0e4d143e7a4581419 (patch)
tree5e15f6dfc34f7098c11854b30bcfab825fa91991
parent0c0284e6f8f6930c957e569013bb5688bfc1ad01 (diff)
downloadbugzilla-09ff98ad16f9301c36b21fd0e4d143e7a4581419.tar.gz
bugzilla-09ff98ad16f9301c36b21fd0e4d143e7a4581419.tar.xz
Bug 1166777: Script for generating API keys
-rwxr-xr-xcontrib/issue-api-key.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/issue-api-key.pl b/contrib/issue-api-key.pl
new file mode 100755
index 000000000..fe24f59df
--- /dev/null
+++ b/contrib/issue-api-key.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+use strict;
+use feature 'say';
+
+use FindBin qw( $RealBin );
+use lib "$RealBin/..";
+use lib "$RealBin/../lib";
+
+use Bugzilla;
+use Bugzilla::Constants;
+use Bugzilla::User;
+use Bugzilla::User::APIKey;
+
+Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+
+my $login = shift
+ or die "syntax: $0 bugzilla-login [description]\n";
+my $description = shift;
+
+my $user = Bugzilla::User->check({ name => $login });
+my $api_key = Bugzilla::User::APIKey->create({
+ user_id => $user->id,
+ description => $description,
+});
+say $api_key->api_key;