Revoke Api Keys

We are currently trying out openBalena and recently figured out that we could use “generate api-key” to get a key we can use to log in. Now the question, where are these Keys saved and can they be deleted/revoked somehow?

Can you specify where/how you’re generate the API key ? Are you using balena CLI Documentation - Balena Documentation ?

Hi @luclucluca I’m just sharing some more of our docs on generating API keys in case they are useful to you

The second link there has a code snippet for deleting an API key which should hopefully work for you if you want to delete any of your existing keys

Yes that’s how we generated them.

Thank you very much! I’ll try these tomorrow.

great, let us know if you have any more questions :blush:

Thanks very much for the Great help! We are able now the see all the generated api keys! Tho it seems that, since we use those generated api keys to access them, we dont have the permission do Delete any api keys. I’ve read before about a “supervisor” api key but we were unable to find it anywhere. Does that also exist in openBalena? If yes where do we find it or how do we generate it?

Thanks in Advance!

Any news here? @Lizzieepton

Hello @luclucluca

Could you please confirm if you have set the io.balena.features.supervisor-api on your docker-compose file? Then running echo $BALENA_SUPERVISOR_API_KEY that should work.

Let me know if that solves the question or we can help you more! (sorry for the delay).

Only the admin user (using credentials to log-in) could delete this if I am correct.
I guess you could generate a temporary token using the credentials and then use that token to delete whatever you want.

I believe the main API key can be found in your docker compose/environment file.

We are creating the Tokens using the Admin user(The account we used to set up the server). Even then if i send a DELETE Request for a api Key I get an “Unauthorized” back. I couldnt find any API keys that work in the Docker compose files on the server.

If you first authenticate with the admin user using the API, you get a token back.
Try use this token to delete the API keys.

How would you authenticate with the API?

Hello @luclucluca

I made a very quick and dirty bash script you can use to revoke API keys. Not clean at all but it works.
You can find it here: GitHub - robbe-haesendonck/open-balena-scripts: Some scripts for interacting with the open-balena API

Will probably put some time in cleaning it up some day

Best regards,
Robbe

1 Like

This is exactly what I was looking for. Thank you very much!