How to create API token automatically?

Hi there,

I’m trying to find a way to programatically create API tokens for various organizations. I’ve read through the following Github issues:

So it appears you can use basic auth to authenticate to the API. However, is there a way to generate an API token after using Basic Auth?

See this answer: How to get the API key from REST API or other scripts?