Question: How to generate a Galaxy API key without the web-interface
gravatar for vaskin90
4.6 years ago by
vaskin9030 wrote:

I need to setup Galaxy on a server for NGS analysis. The server is pretty closed and internal and I there is no HTTP server. I don't have root permissions as well. I'm going to control the Galaxy instance through API. But the problem is that I cannot generate an API key. How can I do it through the API, without the web-interface?

api galaxy • 2.1k views
ADD COMMENTlink modified 4.6 years ago by jmchilton1.1k • written 4.6 years ago by vaskin9030
gravatar for jmchilton
4.6 years ago by
United States
jmchilton1.1k wrote:

You can set `master_api_key` in your Galaxy's `universe_wsgi.ini` file to have an admin key capable of using some of the API without being  tied to a particular user. Some API endpoints will not work without a real user however, so I would then use this key to generate a user and then an API key for this user (or just the API key a user already exists). To create a user you can use a `POST` to `/api/users` with a `username`, `password`, and `email` in the payload.  You can POST to /api/users/{encoded_user_id}/api_key with the created user's encoded id to get an API key for that user.

bioblend and blend4j - the Python and Java libraries for targeting the Galaxy API - already have utility methods for performing these actions against the Galaxy API and I would recommend using these. Also, if you want to create users and API keys in batch without setting a `master_api_key` there is a seed script that can by adapted that targets the Galaxy database and can do this. This is how the Galaxy Bootstrap creates Galaxy instances with pre-populated users and API keys.

ADD COMMENTlink written 4.6 years ago by jmchilton1.1k
gravatar for Martin Čech
4.6 years ago by
Martin Čech ♦♦ 4.9k
United States
Martin Čech ♦♦ 4.9k wrote:

To obtain the API key using user credentials call here:

GET /api/authenticate/baseauth

but it does not generate the key for you if the key does not exist.

However you might be able to add the API key to the DB directly for specific user. I suggest running a clean Galaxy elsewhere and see what rows does it create when you generate API key.

edit: John's solution is way better than mingling with the DB, go with it.

ADD COMMENTlink modified 4.6 years ago • written 4.6 years ago by Martin Čech ♦♦ 4.9k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 168 users visited in the last hour