Copilot Studio Kit supports testing custom Agents with user authentication using Entra ID v2 (Azure Active Directory v2) as the service provider with SSO enabled. These instructions include all the steps required to enable end user authentication on your agent in Copilot Studio, create and configure the required applications in Azure Portal and finally create the agent configuration in Copilot Studio Kit.
- Copilot Studio Kit has been installed
Related instructions in Microsoft Learn: https://learn.microsoft.com/en-us/microsoft-copilot-studio/configure-sso?tabs=classic#create-an-app-registration-in-microsoft-entra-id-for-your-custom-canvas
- Navigate to Azure Portal
- Navigate to App registrations in Azure Portal
- Select New registration
- Enter a name for your application. We will call this application "KitAuthApp".
- Under Supported account types, select Accounts in any organizational tenant (Any Microsoft Entra ID directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox).
- Leave the Redirect URI section blank for now. We will be entering that information later in the next steps.
- Select Register, you will be sent to the "Overview"-page of your new application.
- Make note of the "Directory (tenant) ID" and "Application (client) ID". We will need these when creating agent registration in Copilot Studio Kit and associating the Copilot Studio with the Copilot Studio Kit app.
- Expand Manage and select Authentication
- Under Platform configurations, select Add a platform, and then select Single-page application.
- Under Redirect URIs, enter your Dataverse environment URL (https://<hostname>.crm.dynamics.com/)
- In the Implicit grant and hybrid flows-section, turn on both Access tokens (used for implicit flows) and ID tokens (used for implicit and hybrid flows).
- Select Configure to confirm your changes.
- Go to API Permissions.
- Select Grant admin consent for , and then select Yes. If the button isn't available, you might need to ask a tenant administrator to do enter it for you.
Related instructions in Microsoft Learn: https://learn.microsoft.com/en-us/microsoft-copilot-studio/configuration-authentication-azure-ad
- Navigate to Azure Portal
- Navigate to App registrations in Azure Portal
- Select New registration
- Enter a name for your application. We will call this application "CopilotStudioAuthApp".
- Under Supported account types, select Accounts in any organizational tenant (Any Microsoft Entra ID directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox).
- Leave the Redirect URI section blank for now. We will be entering that information later in the next steps.
- Select Register, you will be sent to the "Overview"-page of your new application.
- Make note of the "Directory (tenant) ID" and "Application (client) ID". We will need these when enabling end user authentication in Copilot Studio.
- Expand Manage and select Authentication
- Under Platform configurations, select Add a platform, and then select Web.
- Under Redirect URIs, enter "https://token.botframework.com/.auth/web/redirect", and select Configure. This action takes you back to the Platform configurations page.
- Under Redirect URIs for the Web platform, select Add URI.
- Enter "https://europe.token.botframework.com/.auth/web/redirect", and select Save.
- 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).
- Select Save
- Under Manage, select Certificates & secrets.
- In the Client secrets section, select New client secret.
- Enter a description. Preferably something descriptive.
- Select the expiry period.
- Select Add to create the secret.
- Make note of the secret's "Value". We will need this when enabling end user authentication in Copilot Studio.
- Under Manage, select API permissions.
- Select Add a permission, and then select Microsoft Graph.
- Select Delegated permissions.
- Expand OpenId permissions and turn on "openid" and "profile".
- (Optional, required for SharePoint knowledge source) Expand Files and turn on Files.Read.All
- (Optional, required for SharePoint knowledge source) Expand Sites and turn on Sites.Read.All
- Select Add permissions
- Select Grant admin consent for , and then select Yes. If the button isn't available, you might need to ask a tenant administrator to do enter it for you.
- Select Expose an API and select Add a scope
- Select Save and continue
- In Scope name, enter descriptive name. We will use copilot.studio.scope.
- Under Who can consent?, select Admins and users
- Enter descriptive name and description in Admin consent display name and Admin consent description
- Ensure State is Enabled
- Select Add scope
- Make note of the full scope name under Scopes. We will need this later when enabling end user authentication in Copilot Studio. (api://xxx/copilot.studio.scope)
- Select Add a client application
- In Client ID, enter the Client ID of the "KitAuthApp" that we created earlier.
- Verify that the scope in Authorized scopes is the one that you created earlier (copilot.studio.scope). Turn on (check) that scope.
- Select Add application.
Related instructions in Microsoft Learn: https://learn.microsoft.com/microsoft-copilot-studio/configure-sso and https://learn.microsoft.com/microsoft-copilot-studio/nlu-generative-answers-sharepoint-onedrive#advanced-authentication-scenarios
- Navigate to Copilot Studio
- Open Settings
- Select Security
- Select Authentication
- Select Authenticate manually
- Enable Require users to sign in
- Do not change Redirect URL, make sure Service provider is Azure Active Directory v2.
- In Client ID, enter the Client ID of CopilotStudioAuthApp
- In Client secret, enter the Client secret created for CopilotStudioAuthApp
- In Token exchange URL, enter the full name of the scope (api://xxx/copilot.studio.scope) that we created for CopilotStudioAuthApp
- (Optional, required for SharePoint knowledge source) In Scopes, add Files.Read.All
- (Optional, required for SharePoint knowledge source) In Scopes, add Sites.Read.All
- Click Save, then Save again from the dialog.
- Close Settings
- Click Publish, then Publish again from the dialog.
Related instructions in the Copilot Studio Kit repository: https://github.com/microsoft/Power-CAT-Copilot-Studio-Kit/blob/main/CONFIGURE_COPILOTS.md
- Navigate to Copilot Studio Kit
- Select Agents from the navigation.
- Click New
- Enter Name
- From Configuration Type(s) select Test Automation
- Fill Direct Line Settings-section, enter either Token Endpoint or enable Channel Security and enter Direct Line secret.
- In User Authentication-section, for User Authencation select Entra ID v2
- For Client ID, enter the Client ID of KitAuthApp
- For Tenant ID enter the Directory ID of KitAuthApp
- For Scope, enter the full scope name (api://xxx/copilot.studio.scope) created for CopilotStudioAuthApp
- Click Save & Close
Now you are ready to start testing your agent with end user authentication enabled!
To recap what we did here:
- Created app registration specifically for Copilot Studio Kit authentication purpose
- Created app registration for Copilot Studio authentication
- Linked the applications so that Copilot Studio Kit is able to authenticate to Direct Line via Copilot Studio authentication application
- Enabled authentication in custom agent in Copilot Studio
- Created agent configuration in Copilot Studio Kit with end user authentication enabled