@pnp/cli-microsoft365
Version:
Manage Microsoft 365 and SharePoint Framework projects on any platform
38 lines • 1.38 kB
JavaScript
import { z } from 'zod';
import { globalOptionsZod } from '../../../../Command.js';
import { formatting } from '../../../../utils/formatting.js';
import { odata } from '../../../../utils/odata.js';
import GraphCommand from '../../../base/GraphCommand.js';
import commands from '../../commands.js';
export const options = globalOptionsZod
.extend({
spObjectId: z.uuid().alias('i')
}).strict();
class EntraOAuth2GrantListCommand extends GraphCommand {
get name() {
return commands.OAUTH2GRANT_LIST;
}
get description() {
return 'Lists OAuth2 permission grants for the specified service principal';
}
defaultProperties() {
return ['objectId', 'resourceId', 'scope'];
}
get schema() {
return options;
}
async commandAction(logger, args) {
if (this.verbose) {
await logger.logToStderr(`Retrieving list of OAuth grants for the service principal...`);
}
try {
const res = await odata.getAllItems(`${this.resource}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${formatting.encodeQueryParameter(args.options.spObjectId)}'`);
await logger.log(res);
}
catch (err) {
this.handleRejectedODataJsonPromise(err);
}
}
}
export default new EntraOAuth2GrantListCommand();
//# sourceMappingURL=oauth2grant-list.js.map