Configure user authentication with Microsoft Entra ID

Adding authentication to your agent allows users to sign in, giving your agent access to a restricted resource or information.

This article covers how to configure Microsoft Entra ID as your service provider. To learn about other service providers and user authentication in general, see Configure user authentication in Copilot Studio.

If you have tenant administration rights, you can configure API permissions. Otherwise, you need to ask a tenant administrator to do it for you.

Prerequisites

Learn how to add user authentication to a topic

You complete the first several steps in the Azure portal, and complete the final two steps in Copilot Studio.

Create an app registration

  1. Sign in to the Azure portal, using an admin account in the same tenant as your agent.

  2. Go to App registrations.

  3. Select New registration and enter a name for the registration. Don't alter existing app registrations.

    It can be helpful later to use the name of your agent. For example, if your agent is called "Contoso sales help," you might name the app registration "ContosoSalesReg."

  4. Under Supported account types, select Accounts in any organizational tenant (Any Microsoft Entra ID directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox).

  5. Leave the Redirect URI section blank for now. Enter that information in the next steps.

  6. Select Register.

  7. After the registration is complete, go to Overview.

  8. Copy the Application (client) ID and paste it in a temporary file. You need it in later steps.

Add the redirect URL

  1. Under Manage, select Authentication.

  2. Under Platform configurations, select Add a platform, and then select Web.

  3. Under Redirect URIs, enter https://token.botframework.com/.auth/web/redirect, and select Configure.

    This action takes you back to the Platform configurations page.

  4. Under Redirect URIs for the Web platform, select Add URI.

  5. Enter https://europe.token.botframework.com/.auth/web/redirect, and select Save.

    Note

    The authentication configuration pane in Copilot Studio might show the following redirect URL: https://unitedstates.token.botframework.com/.auth/web/redirect. Using that URL makes the authentication fail; use the URI instead.

  6. In the Implicit grant and hybrid flows section, select both Access tokens (used for implicit flows) and ID tokens (used for implicit and hybrid flows).

  7. Select Save.

Generate a client secret

  1. Under Manage, select Certificates & secrets.

  2. In the Client secrets section, select New client secret.

  3. (Optional) Enter a description. One is provided if left blank.

  4. Select the expiry period. Select the shortest period that's relevant for the life of your agent.

  5. Select Add to create the secret.

  6. Store the secret's Value in a secure temporary file. You need it when you configure your agent's authentication later on.

Tip

Don't leave the page before you copy the value of the client secret. If you do, the value is obfuscated and you must generate a new client secret.

Configure manual authentication

  1. In Copilot Studio, go to Settings for your agent, and select Security.

  2. Select Authentication.

  3. Select Authenticate manually.

  4. Leave Require users to sign in on.

  5. Enter the following values for the properties:

    • Service provider: Select Azure Active Directory v2.

    • Client ID: Enter the application (client) ID that you copied earlier from the Azure portal.

    • Client secret: Enter the client secret you generated earlier from the Azure portal.

    • Scopes: Enter profile openid.

  6. Select Save to finish the configuration.

Configure API permissions

  1. Go to API permissions.

  2. Select Grant admin consent for <your tenant name>, and then select Yes. If the button isn't available, you might need to ask a tenant administrator to do enter it for you.

    Screenshot of the API permissions window with a tenant permission highlighted.

    Important

    To avoid users having to consent to each application, someone assigned at least the Application Administrator or Cloud Application Administrator role can grant tenant-wide consent to your application registrations.

  3. Select Add a permission, and then select Microsoft Graph.

    Screenshot of the Request API permissions window with Microsoft Graph highlighted.

  4. Select Delegated permissions.

    Screenshot with Delegated permissions highlighted.

  5. Expand OpenId permissions and turn on openid and profile.

    Screenshot with OpenId permissions, openid, and profile highlighted.

  6. Select Add permissions.

Define a custom scope for your agent

Scopes allow you to determine user and admin roles and access rights. You create a custom scope for the canvas app registration that you create in a later step.

  1. Go to Expose an API and select Add a scope.

    Screenshot with Expose an API and the Add a scope button highlighted.

  2. Set the following properties. You can leave the other properties blank.

    Property Value
    Scope name Enter a name that makes sense in your environment, such as Test.Read
    Who can consent? Select Admins and users
    Admin consent display name Enter a name that makes sense in your environment, such as Test.Read
    Admin consent description Enter Allows the app to sign the user in.
    State Select Enabled
  3. Select Add scope.

Configure authentication in Copilot Studio

  1. In Copilot Studio, under Settings, select Security > Authentication.

  2. Select Authenticate manually.

  3. Leave Require users to sign in on.

  4. Select a Service provider and provide the required values. See Configure manual authentication in Copilot Studio.

  5. Select Save.

Tip

The token exchange URL is used to exchange the On-Behalf-Of (OBO) token for the requested access token. For more information, see Configure single sign-on with Microsoft Entra ID.

Note

The scopes should include profile openid and the following, depending on your use case:

  • Sites.Read.All Files.Read.All for SharePoint
  • ExternalItem.Read.All for Graph Connection
  • https://[OrgURL]/user_impersonation for Prompt Nodes and Dataverse structured data
  • For example, Dataverse Structure Data or Prompt Node should have the following scopes: profile openid Sites.Read.All Files.Read.All https://myorg123.com/user_impersonation

Test your agent

  1. Publish your agent.

  2. In the Test agent pane, send a message to your agent.

  3. When the agent responds, select Login.

    A new browser tab opens, asking you to sign in.

  4. Sign in, and then copy the displayed validation code.

  5. Paste the code in the agent chat to complete the sign-in process.

    Screenshot of a successful user authentication in an agent conversation, with the validation code highlighted.