The code below works fine in case of console application but it fails (returns false) to read any file when invoked in a mechanism in Authorization plugin in macOS.