Agent Identity Authentication Fails After Creating Agent Instance from Blueprint (AADSTS50034 / invalid_grant)

Akshay Babar 65 Reputation points
2026-07-01T17:03:25.55+00:00

We are developing an AI teammate agent using the Microsoft Agent 365 SDK.

Our setup process is as follows:

  • We cloned the code from the Agent 365 samples repository.

We used the Agent 365 CLI commands to configure and set up the agent.

We ran a365 setup all --m365, which successfully created the Azure resources, including the blueprint and Azure App Registration.

We are using Dev Tunnel for local testing.

But, after uploading the agent ZIP and creating an agent instance from the blueprint, we are getting the following authentication error:

Unhandled rejection Error: Token request failed with status 400: {"error":"invalid_grant","error_description":"AADSTS50034: The user account {EUII Hidden} does not exist in the <tenant id> directory. To sign into this application, the account must be added to the directory. Trace ID: 5405ebba-13ff-4740-9919-e39443a56200 Correlation ID: e948f327-da45-45ef-b834-cf653f524923 Timestamp: 2026-06-30 17:17:03Z","error_codes":[50034],"timestamp":"2026-06-30 17:17:03Z","trace_id":"5405ebba-13ff-4740-9919-e39443a56200","correlation_id":"e948f327-da45-45ef-b834-cf653f524923","error_uri":"https://login.microsoftonline.com/error?code=50034"}
    at C:\project\ifs-loops-agent\node_modules\@microsoft\agents-hosting\src\auth\msalTokenProvider.ts:331:23
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MsalTokenProvider.acquireTokenForAgenticScenarios (C:\project\ifs-loops-agent\node_modules\@microsoft\agents-hosting\src\auth\msalTokenProvider.ts:318:19)
    at async C:\project\ifs-loops-agent\node_modules\@microsoft\agents-hosting\src\auth\msalTokenProvider.ts:359:21
    at async C:\project\ifs-loops-agent\node_modules\@microsoft\agents-hosting\src\cloudAdapter.ts:387:25
    at async C:\project\ifs-loops-agent\node_modules\@microsoft\agents-hosting\src\cloudAdapter.ts:640:33 {
  toJSON: [Function (anonymous)]

User's image

We have already verified the following:

The signed-in user belongs to the same Microsoft Entra tenant.

The user is a Member and has the Global Administrator role.

The Azure App Registration is associated with the same tenant ID.

Despite these checks, the error still occurs.

Could you please help us identify what we might be missing in the Agent identity authentication flow? Are there any additional configurations or prerequisites that we should verify?

Microsoft Copilot | Microsoft 365 Copilot | Development

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.