UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

49 lines 1.71 kB
import { z } from 'zod'; import { globalOptionsZod } from '../../../../Command.js'; import request from '../../../../request.js'; import GraphCommand from '../../../base/GraphCommand.js'; import commands from '../../commands.js'; export const options = globalOptionsZod .extend({ clientId: z.uuid().alias('i'), resourceId: z.uuid().alias('r'), scope: z.string().alias('s') }).strict(); class EntraOAuth2GrantAddCommand extends GraphCommand { get name() { return commands.OAUTH2GRANT_ADD; } get description() { return 'Grants the specified service principal OAuth2 permissions to the specified resource'; } get schema() { return options; } async commandAction(logger, args) { if (this.verbose) { await logger.logToStderr(`Granting the service principal specified permissions...`); } try { const requestOptions = { url: `${this.resource}/v1.0/oauth2PermissionGrants`, headers: { 'content-type': 'application/json;odata.metadata=none' }, responseType: 'json', data: { "clientId": args.options.clientId, "consentType": "AllPrincipals", "principalId": null, "resourceId": args.options.resourceId, "scope": args.options.scope } }; await request.post(requestOptions); } catch (err) { this.handleRejectedODataJsonPromise(err); } } } export default new EntraOAuth2GrantAddCommand(); //# sourceMappingURL=oauth2grant-add.js.map