Hello @@IamCoder ,
In general, the solution you use is the right solution to get access to the IoT Hub for API functionality.
See also this blog post and this blog post where a similar approach is used for the REST API:
az login
az ad sp create-for-rbac -n "testaccount"
Normally this is provided by an administrator who has access to the production environment. So there is a boundary between programming and service management.
As far as I know, it's not possible to skip it and using eg. the IoT Hub connection string (supporting the right policies).