Description
Summary
When running a365 setup blueprint for a new blueprint, the command successfully opens the browser for admin consent and confirms the grant was created. However, it then attempts a redundant programmatic POST /v1.0/oauth2PermissionGrants for the same grant, which fails with 403 Authorization_RequestDenied. This failure prevents the inheritable permissions manifest from ever being written to the blueprint application, leaving agent instances unable to inherit Microsoft Graph permissions at runtime.
Root Cause
The flow through EnsureAdminConsentAsync (BlueprintSubcommand.cs:1844) for a new blueprint is:
-
Browser consent — BuildAdminConsentUrl() + BrowserHelper.TryOpenUrl() opens /v2.0/adminconsent. Azure creates the oauth2PermissionGrant record when the admin accepts. The CLI polls and confirms success (BlueprintSubcommand.cs:1989–2002).
-
Redundant programmatic grant — EnsureResourcePermissionsAsync is called (BlueprintSubcommand.cs:2023). Inside, Step 2 (SetupHelpers.cs:1557–1580) unconditionally issues POST /v1.0/oauth2PermissionGrants with consentType: AllPrincipals via GraphApiService.CreateOrUpdateOauth2PermissionGrantWithDetailsAsync. The Graph API returns 403 Authorization_RequestDenied because creating AllPrincipals grants programmatically requires Global Administrator backing on the CLI's delegated token, even though the same grant was just established interactively by the admin in the browser (GraphApiService.cs:909–913). A SetupValidationException is thrown at SetupHelpers.cs:1576.
-
Inheritable permissions never reached — Step 3 (SetupHelpers.cs:1587), which calls AgentBlueprintService.SetInheritablePermissionsAsync, is never executed. This step writes an allAllowed inheritable permissions manifest entry to the blueprint application object via POST /beta/applications/microsoft.graph.agentIdentityBlueprint/{objectId}/inheritablePermissions (AgentBlueprintService.cs:451–472). Without it, the Agent Identity platform has no declaration of which scopes agent instances may inherit from the blueprint, so instances cannot use the consented Graph permissions at runtime.
Misleading Error Message
The outer catch at BlueprintSubcommand.cs:1956–1961 logs the failure as "Failed to configure Microsoft Graph inheritable permissions". This is inaccurate — the inheritable permissions API was never called. The actual failure is in the OAuth2 grant POST (Step 2). This makes the error harder to diagnose, since it implies the AgentIdentityBlueprint.ReadWrite.All scope is the issue, when the real cause is the redundant AllPrincipals grant attempt.
Expected behavior
After a successful browser admin consent, EnsureResourcePermissionsAsync should skip the POST /v1.0/oauth2PermissionGrants step (or treat the existing grant as sufficient) and proceed directly to Step 3 to write the inheritable permissions manifest on the blueprint application object.
SDK Version
1.1.206
Language/Runtime
.NET 10.0.300
OS
macOS
How to Reproduce
Steps to Reproduce
- Run:
a365 setup blueprint --agent-name <name> --tenant-id <tenant>
- Grant consent in the browser when prompted. Observe the output:
--> Consent granted (Graph API Scopes).
--> Graph API admin consent granted successfully!
--> Configuring inheritable permissions for Microsoft Graph...
--> OAuth2 permission grant failed (non-transient) for resource <resource-id> with scopes [...]. Graph response: {"error":{"code":"Authorization_RequestDenied",...}}
--> Failed to configure Microsoft Graph inheritable permissions: [SETUP_VALIDATION_FAILED] Failed to create/update OAuth2 permission grant from blueprint <id> to Microsoft Graph 00000003-0000-0000-c000-000000000000. This may be due to insufficient permissions. Ensure you have AgentIdentityBlueprint.ReadWrite.All permission consented on your client app.
--> Agent instances may not be able to access Microsoft Graph resources
Output
Agent % a365 setup blueprint --agent-name AgentV2 --tenant-id
Resolving client app by display name "Agent 365 CLI"...
Checking requirements...
Pass: Azure Authentication
Warn: Frontier Preview Program - Tenant enrollment cannot be verified automatically - Ensure your tenant is enrolled before proceeding. See: https://adoption.microsoft.com/copilot/frontier-program/
Pass: PowerShell Modules (Microsoft.Graph.Authentication, Microsoft.Graph.Applications)
Pass: Client App Configuration ()
Pass: Client App 'wids' Optional Claim ('wids' is present on accessToken optionalClaims for )
Requirements: 4 passed, 1 warnings, 0 failed
Starting blueprint setup... (TraceId: )
Creating agent blueprint...
Verifying consent for agent blueprint operations...
Successfully ensured delegated application consent
Creating blueprint application...
Sign in to Microsoft Graph to continue...
Authenticating to Microsoft Graph...
Successfully authenticated to Microsoft Graph!
Current user: <>
Display Name: AgentV2 Blueprint
Sponsor and Owner: User ID
Blueprint application created successfully
Blueprint ID:
Waiting for application to propagate in directory...
Creating blueprint service principal...
Blueprint service principal ID: <BLUEPRINT-SP-ID>
Adding access_agent_as_user scope to blueprint...
access_agent_as_user scope added to blueprint
Requesting admin consent for application
Opening browser for Graph API admin consent...
If the browser does not open automatically, navigate to this URL to grant consent: https://login.microsoftonline.com/<TENANT-ID>/v2.0/adminconsent?client_id=<BLUEPRINT-APP-ID>&scope=.....
Sign in and Accept the permission(s). If the tab shows an error after Accept, consent likely succeeded — the CLI will still detect it (timeout: 180s).
Consent granted (Graph API Scopes).
Graph API admin consent granted successfully!
Configuring inheritable permissions for Microsoft Graph...
OAuth2 permission grant failed (non-transient) for resource <GRAPH-SP-OBJECT-ID> with scopes [Mail.ReadWrite Mail.Send Chat.ReadWrite User.Read.All Sites.Read.AllFiles.ReadWrite.All ChannelMessage.Read.All ChannelMessage.Send]. Graph response: {"error":{"code":"Authorization_RequestDenied","message":"Insufficient privileges to complete the operation.","innerError":{"date":"2026-06-10T12:30:17","request-id":"<REQUEST-ID>","client-request-id":"<CLIENT-REQUEST-ID>"}}}
Failed to configure Microsoft Graph inheritable permissions: [SETUP_VALIDATION_FAILED] Failed to create/update OAuth2 permission grant from blueprint <BLUEPRINT-APP-ID> to Microsoft Graph 00000003-0000-0000-c000-000000000000. This may be due to insufficient permissions. Ensure you have AgentIdentityBlueprint.ReadWrite.All permission consented on your client app.
Agent instances may not be able to access Microsoft Graph resources
You can configure these manually later with: a365 setup blueprint
Creating blueprint client secret...
DPAPI encryption not available on this platform. Secret will be stored in plaintext.
Client secret created successfully!
Blueprint client secret: <REDACTED-SECRET>
Copy this value now — it will not be shown again automatically.
To retrieve it later, run 'a365 setup blueprint --show-secret' from the same folder.
Keep your credentials secure and do not commit them to source control!
Verification URLs:
Entra ID Application: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Overview/appId/
Configuring custom blueprint permissions...
No custom blueprint permissions specified in config. Skipping.
Next steps:
1. Run 'a365 setup permissions mcp' to configure MCP permissions
2. Run 'a365 setup permissions bot' to configure Bot API permissions
Screenshots
No response
Code of Conduct
Description
Summary
When running
a365 setup blueprintfor a new blueprint, the command successfully opens the browser for admin consent and confirms the grant was created. However, it then attempts a redundant programmatic POST /v1.0/oauth2PermissionGrants for the same grant, which fails with 403 Authorization_RequestDenied. This failure prevents the inheritable permissions manifest from ever being written to the blueprint application, leaving agent instances unable to inherit Microsoft Graph permissions at runtime.Root Cause
The flow through EnsureAdminConsentAsync (BlueprintSubcommand.cs:1844) for a new blueprint is:
Browser consent — BuildAdminConsentUrl() + BrowserHelper.TryOpenUrl() opens /v2.0/adminconsent. Azure creates the oauth2PermissionGrant record when the admin accepts. The CLI polls and confirms success (BlueprintSubcommand.cs:1989–2002).
Redundant programmatic grant — EnsureResourcePermissionsAsync is called (BlueprintSubcommand.cs:2023). Inside, Step 2 (SetupHelpers.cs:1557–1580) unconditionally issues POST /v1.0/oauth2PermissionGrants with consentType: AllPrincipals via GraphApiService.CreateOrUpdateOauth2PermissionGrantWithDetailsAsync. The Graph API returns 403 Authorization_RequestDenied because creating AllPrincipals grants programmatically requires Global Administrator backing on the CLI's delegated token, even though the same grant was just established interactively by the admin in the browser (GraphApiService.cs:909–913). A SetupValidationException is thrown at SetupHelpers.cs:1576.
Inheritable permissions never reached — Step 3 (SetupHelpers.cs:1587), which calls AgentBlueprintService.SetInheritablePermissionsAsync, is never executed. This step writes an allAllowed inheritable permissions manifest entry to the blueprint application object via POST /beta/applications/microsoft.graph.agentIdentityBlueprint/{objectId}/inheritablePermissions (AgentBlueprintService.cs:451–472). Without it, the Agent Identity platform has no declaration of which scopes agent instances may inherit from the blueprint, so instances cannot use the consented Graph permissions at runtime.
Misleading Error Message
The outer catch at BlueprintSubcommand.cs:1956–1961 logs the failure as "Failed to configure Microsoft Graph inheritable permissions". This is inaccurate — the inheritable permissions API was never called. The actual failure is in the OAuth2 grant POST (Step 2). This makes the error harder to diagnose, since it implies the AgentIdentityBlueprint.ReadWrite.All scope is the issue, when the real cause is the redundant AllPrincipals grant attempt.
Expected behavior
After a successful browser admin consent, EnsureResourcePermissionsAsync should skip the POST /v1.0/oauth2PermissionGrants step (or treat the existing grant as sufficient) and proceed directly to Step 3 to write the inheritable permissions manifest on the blueprint application object.
SDK Version
1.1.206
Language/Runtime
.NET 10.0.300
OS
macOS
How to Reproduce
Steps to Reproduce
a365 setup blueprint --agent-name <name> --tenant-id <tenant>Output
Agent % a365 setup blueprint --agent-name AgentV2 --tenant-id
Resolving client app by display name "Agent 365 CLI"...
Checking requirements...
Pass: Azure Authentication
Warn: Frontier Preview Program - Tenant enrollment cannot be verified automatically - Ensure your tenant is enrolled before proceeding. See: https://adoption.microsoft.com/copilot/frontier-program/
Pass: PowerShell Modules (Microsoft.Graph.Authentication, Microsoft.Graph.Applications)
Pass: Client App Configuration ()
Pass: Client App 'wids' Optional Claim ('wids' is present on accessToken optionalClaims for )
Starting blueprint setup... (TraceId: )
Creating agent blueprint...
Verifying consent for agent blueprint operations...
Successfully ensured delegated application consent
Creating blueprint application...
Sign in to Microsoft Graph to continue...
Authenticating to Microsoft Graph...
Successfully authenticated to Microsoft Graph!
Current user: <>
Display Name: AgentV2 Blueprint
Sponsor and Owner: User ID
Blueprint application created successfully
Blueprint ID:
Waiting for application to propagate in directory...
Verification URLs:
Entra ID Application: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Overview/appId/
Configuring custom blueprint permissions...
No custom blueprint permissions specified in config. Skipping.
Next steps:
1. Run 'a365 setup permissions mcp' to configure MCP permissions
2. Run 'a365 setup permissions bot' to configure Bot API permissions
Screenshots
No response
Code of Conduct