web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Unable to Generate Dir...
Copilot Studio
Suggested Answer

Unable to Generate Direct Line Token When Using "Authenticate with Microsoft" in Copilot Studio

(0) ShareShare
ReportReport
Posted on by 2

Hi Team,

I am new to the Microsoft authentication model and would appreciate some guidance on how Direct Line API should be used with a Copilot Studio agent.

My Scenario

I have created a Copilot Studio agent and want to connect it from my own application using the Direct Line API.

The authentication setting of my agent is currently:

Authenticate with Microsoft

What I'm Trying

I am following the Direct Line documentation and trying to generate a Direct Line token by calling:

 
However, the response is:
{
"error": {
"code": "ResourceNotFound",
"message": "Site missing. 1: Learn more about sites https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0#add-new-site. 2: If you are using regional bot, please make sure you are using <region>.*.botframework.com. Learn more https://docs.microsoft.com/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0#generate-a-direct-line-token"
}
}
 

My Questions


  1. Does this error occur because my agent is configured with "Authenticate with Microsoft"?

  2. Is it possible to use Direct Line API with a Copilot Studio agent when Microsoft authentication is enabled?

  3. If yes:
    • What additional configuration is required?

    • Do I need to configure Microsoft Entra ID manually?

    • How should user authentication tokens be passed to the agent?
  4.  

    If Direct Line API is not supported in this scenario:

    • What is the recommended approach to connect a custom application to a Copilot Studio agent while keeping Authenticate with Microsoft enabled?
  5.  

    Is there any official architecture or sample showing:

    • Custom Application

    • Microsoft Entra ID Authentication

    • Copilot Studio Agent

    • Direct Line AP  

Additional Context

My goal is:


  • Users authenticate with Microsoft Entra ID.

  • My custom application connects to the Copilot Studio agent.

  • The agent can identify the signed-in user and enforce authorization.

  • I would like to understand the correct authentication flow and whether Direct Line is the right approach for this architecture.

I am confused about the relationship between:


  • Direct Line Secret

  • Direct Line Token

  • "Authenticate with Microsoft" in Copilot Studio

  • Microsoft Entra ID Access Token

Are all of them required in the same solution, or are they used for different purposes?

Any guidance or sample implementations would be greatly appreciated.

 

Thanks!

I have the same question (0)
  • Suggested answer
    Sam_Fawzi Profile Picture
    980 Super User 2026 Season 1 on at
    Good question, and you've already half answered it yourself in your first bullet.
     
    WHY YOU GET "SITE MISSING"
    That endpoint belongs to Azure Bot Service Direct Line, and it expects a Direct Line secret tied to a provisioned site. Copilot Studio never issues you one when the agent is set to Authenticate with Microsoft. With that option selected, the agent is restricted to Microsoft first party channels such as Teams and Microsoft 365 Copilot, and Direct Line isn't one of them. No Direct Line site exists for your agent, hence ResourceNotFound. The error text pointing you at the Azure Bot Service site documentation is unhelpful here, because none of that applies to a Copilot Studio agent.
     
    Same reason the embed code disappears. It's only visible when No authentication is selected. Choose Authenticate with Microsoft or Authenticate manually and it's gone.
     
    So to your second question: no, Direct Line can't be used while Microsoft authentication is enabled. Direct Line needs either No authentication or Authenticate manually.
     
    WHAT YOU ACTUALLY WANT, GIVEN YOUR STATED GOAL
    Don't use Direct Line. Use the Microsoft 365 Agents SDK with the Copilot Studio Client. It's built for exactly the architecture you described, and it expects Authenticate with Microsoft, so you keep the setting you already have.
     
    1. Leave the agent on Authenticate with Microsoft
    2. Go to the Channels page, select Web app or Native app, copy the connection string
    3. Register your custom app in Entra ID and grant it the Copilot Studio scope
    4. Your app signs the user in with MSAL and passes that token to CopilotStudioClient
    5. The agent resolves the signed in user into the System.User variables, and connector actions run as that user
    One app registration, real Entra ID SSO, no magic code prompts, and no Direct Line secret anywhere in your stack.
     
    IF YOU'RE FORCED ONTO DIRECT LINE
    If you have non Entra users, or you specifically need a public API rather than an SDK, the path is heavier. Switch to Authenticate manually with your own Entra ID app registration, then configure SSO for a custom canvas: a separate app registration for the canvas, define a custom scope on the agent, add that scope to the agent configuration, and handle the OAuth card token exchange in your client code. Five steps, all of them easy to get subtly wrong.
     
    YOUR LAST QUESTION, THE FOUR TOKENS
    They sit on two unrelated layers.
    Transport layer, meaning "is my application allowed to talk to this agent":
    Direct Line secret. Long lived channel credential. Server side only, never in a browser.
    Direct Line token. Short lived, scoped to a single conversation, minted from the secret on your server. This is the one that's safe to hand to a client.
    Identity layer, meaning "who is the human talking":
     
    Authenticate with Microsoft. The agent setting that forces user sign in and populates the System.User variables.
    Entra ID access token. The user's identity, acquired by your application, passed through to the agent.
    They aren't alternatives, and they aren't all required together. On the Direct Line path you need all four. On the Agents SDK path the first two disappear entirely, because the Entra ID token covers both transport and identity. That collapse is the main reason to prefer it.
    For a working sample plus a walkthrough of every integration option, the Copilot Studio CAT team guide is the most current thing available: https://microsoft.github.io/mcscatblog/posts/copilot-studio-api-decision-guide/
     
     
    One last thing, since you mentioned you're new to this. Authentication changes only take effect after you republish the agent (I learned it the hard way, lol). If you switch auth modes and immediately test against the old channel configuration, you'll get misleading errors that look unrelated to what you changed.
     
     
    Hope that helps. If it does, please mark it as the answer so others can find it.
  • PW-29070411-0 Profile Picture
    2 on at
    Thank you very much for your reply. I noticed in the new version of Copilot Studio that it seems to only support Direct Line. Could you please confirm if this is correct? Also, if I use the Microsoft 365 Agents SDK, will it still be supported? Additionally, it appears that the Environment ID is no longer available in the new version.
  • Suggested answer
    Sam_Fawzi Profile Picture
    980 Super User 2026 Season 1 on at
    Nothing has been removed. Three quick clarifications:
     
    Direct Line isn't the only option. It's now positioned as the fallback: use it "when the Microsoft 365 Agents SDK doesn't support your scenario" (their example is service principal tokens). The SDK connection string isn't on its own page, which is why it's easy to miss:
     
    Channels → Web app (or Native app) → connection string under Microsoft 365 Agents SDK → Copy
    What actually disappeared for you is the Embed code, not the SDK. That only renders under No authentication. With Authenticate with Microsoft you get the connection string only.
     
    Agents SDK is still supported and still the recommended path. Doc was refreshed recently, samples for .NET/JS/Python all maintained.
    https://learn.microsoft.com/en-us/microsoft-copilot-studio/publication-integrate-web-or-native-app-m365-agents-sdk
    https://github.com/microsoft/Agents/tree/main/samples/dotnet/copilotstudio-client
    Environment ID moved, didn't vanish: Settings → Advanced → Metadata (behind the gear icon in the new UI). Though you likely don't need it. Two config styles, pick one, don't mix:
     
    Connection string: DirectConnectUrl, TenantID, ClientID, ClientSecret
    Traditional: EnvironmentID, SchemaName, TenantID, AppClientID, AppClientSecret
    The connection string already encodes environment and schema name.
     
    So the stack from my last reply stands: keep Authenticate with Microsoft, grab the connection string, app registration with Copilot Studio.Copilots.Invoke delegated,
     
    MSAL token into CopilotStudioClient, republish after any auth change.
     
    Hope that clears it up. If it did, marking it as the answer helps the next person.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
11manish Profile Picture

11manish 122

#2
Haque Profile Picture

Haque 105

#3
Valantis Profile Picture

Valantis 103

Last 30 days Overall leaderboard