You must declare the "management" permission in the extension manifest to use the management API. For example:
{ "name": "My extension", ... "permissions": [ "management" ], ... }
$ref:management.getPermissionWarningsByManifest and $ref:management.uninstallSelf do not require the management permission