Create API key for a user programmatically

TL;DR Can API key for a user be created through REST API with credentials o=
f superadmin?

I have a backend system with its own AUTH mechanism. Users can be added and=
 removed dynamically. I am using bugzilla for managing support tickets. We =
have our own front-end through which user will interact with the system. Th=
is includes creating bugs, adding comments, and doing various updates.

I want to be able to add users dynamically, which is possible through REST =
API in v5 (current stable). I cannot however add API key for a user dynamic=
ally. For now, I think doing the auth via loginid and password is the way t=
o go. However, this is marked as "Will be removed in future", with recommen=
ded way for auth being the API key.

Can a superadmin, whose API key already exists, create users, and then crea=
te their API keys as well, all through REST APIs?
7/7/2018 12:42:41 PM 9973 articles. 0 followers. Post Follow

1 Replies

Similar Articles

[PageSpeed] 11

Guten Tag,
am Samstag, 7. Juli 2018 um 14:42 schrieben Sie:

> TL;DR Can API key for a user be created through REST API with credentials=
 of superadmin?

I don't see a way as well, but with the help of extensions you are
able to create your own API-endpoint to create a user incl. an API-key
or only an API-key or whatever use-case you need in the end.

"object_end_of_create" is used during user creation in

Creating aPI-keys is easy and can be seen in userprefs.cgi:

>    # Create a new API key if requested.
>    if ($cgi->param('new_key')) {
>        $vars->{new_key} =3D Bugzilla::User::APIKey->create({
>            user_id     =3D> $user->id,
>            description =3D> scalar $cgi->param('new_description'),
>        });
>        # As a security precaution, we always sent out an e-mail when
>        # an API key is created
>        my $template =3D Bugzilla->template_inner($user->setting('lang'));
>        my $message;
>        $template->process('email/new-api-key.txt.tmpl', $vars, \$message)
>          || ThrowTemplateError($template->error());
>        MessageToMTA($message);
>    }

Mit freundlichen Gr=FC=DFen,

Thorsten Sch=F6ning

Thorsten Sch=F6ning       E-Mail:
AM-SoFT IT-Systeme

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Gesch=E4ftsf=FChrer: Andreas Muchow

7/8/2018 11:51:41 AM