Hot to set TOKEN for API? Sentry 8.22

I can’t find where the TOKEN for API may be created.
I haven’t found any option for it in ‘user settings’ as suggested here: How to get information by sentry web api

I tried specifying it either as env variable for sentry:8.22 docker container
and as auth.token: 'sometoken' in config.yml
Still, I get the {"detail": "Invalid token"} response trying to query API like this:
curl -H 'Authorization: Bearer sometoken' http://localhost:9000/api/0/projects/sentry/ueba/issues/

How it should be specified? I am especially curious about user settings option, menthioned in the other thread

I reply to you in How to get information by sentry web api.
Hope this can help you.

Thank you very much! It does help, at least for development purposes.
But we are creating new Sentry instance from docker, therefore I need to be able to set these token programmatically, and so I need to get how to set it by config file or env var.

For the community:
We ended up creating user, project and API token programmatically, running scripts like this:

import sys
from sentry.runner import configure
configure()
from sentry.models import ApiToken
from sentry.models import User

username = sys.argv[1]
API_token = sys.argv[2]
try:
    user = User.objects.get(username=username)
    ApiToken.objects.create(user=user, token=API_token, scopes=0,
                            scope_list=['event:admin', 'event:read', 'member:read', 'org:read', 'project:read',
                                        'project:releases', 'team:read'])
except Exception as e:
    print("failed to create Sentry API token: %s" % (e,))
2 Likes