Skip to content

New-Agent365ToolsServicePrincipalProdPublic.ps1 requests insufficient Graph scope — 403 on `New-MgServicePrincipal #414

@pdwarf

Description

@pdwarf

Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All" -NoWelcome

Connect-MgGraph on line 193 requests only AppRoleAssignment.ReadWrite.All. New-MgServicePrincipal requires Application.ReadWrite.All. The V1 ATG SP is typically pre-existing so it skips past, but any V2 per-server SP that needs creation hits Authorization_RequestDenied (403).

Fix: add Application.ReadWrite.All to the -Scopes array.

- Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All" -NoWelcome
+ Connect-MgGraph -Scopes "Application.ReadWrite.All","AppRoleAssignment.ReadWrite.All" -NoWelcome

CLI version: 1.1.176, PowerShell 7.5.4, macOS.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions