We are creating machine-to-machine applications using the Management API (Auth0 Management API v2) and this works perfectly. However, we would also like to authenticate these applications for certain APIs we have defined in Auth0 and it is currently not clear how to do this using the Management API.
Without this functionality, an Auth0 admin has to manually authorize the generated application to use an API using the Auth0 dashboard and this kind of defeats the purpose of automating the app creation.
Sorry for the delay in response. There are a lot of community developers asking questions out there and we’re doing our best to provide regularly knowledge and support to all of you but sometimes we’re simply people resources constraint. Thank you for understanding and sorry for the inconvenience!
Yes, you are right about auth before using the API. But before all this, the API to be called has to be enabled or authorised for the specific app at Auth0. This can be done using the Auth0 Manage tool after the app has been created (by going to Applications > you app > APIs tab > selecting an API) and the Manage tool also asks for you to select an API to enable when creating a new M2M app. However, the Management API documentation does not mention a way to specify an API to enable/authorise. And that is needed to automate the whole process.
The page @konrad.sopala linked has what you are looking for
There is a section (Update Grant Types) on how to authorize an Application for a given API (audience) using the Management API (Auth0 Management API v2). This is what you’re looking for.
We use something along the lines of (Node.js SDK):