Invalid token error while using management API

You’re trying to use an ID token against the Management API so the 401 is the expected behavior for new tenants/domains or an existing tenants where the Allow ID Tokens for Management API v2 Authentication toggle was disabled.