Skip to content

Commit 16576f1

Browse files
committed
Fix Graph scope in SP provisioning script (issue #414)
New-MgServicePrincipal requires Application.ReadWrite.All, not AppRoleAssignment.ReadWrite.All. The script never calls any app-role- assignment APIs, so requesting that scope was both insufficient (caused 403 Authorization_RequestDenied when creating V2 per-server SPs) and unnecessary over-scope. Replace with the correct least-privilege scope and update the matching 403 error hint so it no longer points users at a permission that wouldn't fix their problem.
1 parent b76c963 commit 16576f1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/cli/Auth/New-Agent365ToolsServicePrincipalProdPublic.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Write-Host "You need admin permissions for this operation." -ForegroundColor Yel
190190
Write-Host ""
191191

192192
try {
193-
Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All" -NoWelcome
193+
Connect-MgGraph -Scopes "Application.ReadWrite.All" -NoWelcome
194194
$context = Get-MgContext
195195
Write-Host "Connected to tenant: $($context.TenantId)" -ForegroundColor Green
196196
Write-Host ""
@@ -231,7 +231,7 @@ catch {
231231
Write-Host "This error usually means you don't have admin permissions." -ForegroundColor Yellow
232232
Write-Host ""
233233
Write-Host "Required Permissions:" -ForegroundColor Cyan
234-
Write-Host " - AppRoleAssignment.ReadWrite.All" -ForegroundColor White
234+
Write-Host " - Application.ReadWrite.All" -ForegroundColor White
235235
Write-Host " - Or Global Administrator / Application Administrator role" -ForegroundColor White
236236
Write-Host ""
237237
Write-Host "Please contact your Microsoft Entra ID administrator to run this script." -ForegroundColor Yellow

0 commit comments

Comments
 (0)