How would a device get its release tags?

I’m trying to get release_tags onboard a device so that I can use the information as metadata. The problem is that the device won’t have an authorization token and won’t be able to perform the query (it’s not worth refreshing tokens on 100+ devices every 7 days).

What’s a better avenue for grabbing the release tags? Is any of that information stored locally? I can get the releaseId from the supervisor, but not tags.

Hey, have you looked at using api keys for auth instead? You can generate them via https://dashboard.balena-cloud.com/preferences/access-tokens and then use them via the authorization header like you do for session tokens

Yeah – thought about that, but also hoping to not have to generate API keys for every single device.

You can try using io.balena.features.balena-api to enable the BALENA_API_KEY env var in the container, see: https://www.balena.io/docs/reference/supervisor/docker-compose/#labels

I’d tried that as well in these two queries:

From developer laptop using developer token

curl -X GET "https://api.balena-cloud.com/v5/release_tag?\$filter=release/commit%20eq%20'e8339bb4fcf9b0d70e1423c611c73c9a'" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat ~/.balena/token)"

In which I get a response full of exactly the data I’d expect.

From device using its BALENA_API_KEY

curl -X GET "https://api.balena-cloud.com/v5/release_tag?\$filter=release/commit%20eq%20'e8339bb4fcf9b0d70e1423c611c73c9a'" -H "Content-Type: application/json" -H "Authorization: Bearer ${BALENA_API_KEY}"

In which my response is only {"d":[]}. (And I do see ${BALENA_API_KEY} print to console when I echo that environment variable)

Also noting that on device I can run

curl -X GET "https://api.balena-cloud.com/v5/application" -H "Content-Type: application/json" -H "Authorization: Bearer ${BALENA_API_KEY}" 

and I get expected data. According to device access docs, it seems like the device’s BALENA_API_KEY is only given access to certain endpoints: /application, /device and /release all work, but /release_tag does not.

I just checked and it looks like the device’s api key doesn’t have access to release tags, I’ll raise if it’s something we want to expose to the device key, aside from that you can use a single api key at the application level that each device shares to avoid needing to generate them individually

1 Like

Great! Where’s the best place to keep an eye out for that change getting released (if it passes muster)?

The feature request should get attached to this and so we’d notify you here if/when we add that access

Hi Nick, just a quick update. This was discussed a while back and it planned to be implemented, but hasn’t been prioritised yet. I have bumped it up the priority list a bit and we will come back to this thread to let you know when its implemented. thanks for the request :slight_smile:

1 Like

Hi @nckswt I just wanted to let you know the feature has been implemented and deployed. You should now be able to access the release tags with the device api key.
Thanks for your suggestion and let us know if everything is working as expected for you.

1 Like