Given Access of Devices to Normal User from CLI or with API

Tags: #<Tag:0x00007f84ab2eb878>

I know that I can give access permission to a devices or ports to specific normal user from Web UI.

But as for automation, I have to do this task in backgroung with some scripting.
Can you please help me the way of giving access permission for a devices to a normal user from CLI or with API