How to configure end-user authentication for actions in Copilot Studio

When makers start building a copilot, they must think about different items such as requirements gathering, action development or fallback strategy. If you need to know the basics of bot building, we highly recommend you to read The PVA Bot Building Handbook (it mentions Power Virtual Agents, but concepts are still valid in Copilot Studio) and the Copilot Studio implementation guide by Microsoft.
Action development is an important element within a conversation, as it is where the bot can perform actions on behalf of the agent or user. In the topic designer, you can add actions that could be any of the following:
- Prebuilt connector action: Use actions based on existing connectors, like MSN Weather or Excel.
- Custom connector action: Use actions based on custom connectors.
- Power Automate cloud flow: Call an existing Power Automate cloud flow.
- AI Builder prompts: Use AI Builder to create a prompt and use it in your action (for instance, classify text or detect sentiment analysis).
- Bot Framework skill: Reuse other bots using skills.
If we want to restrict who can use our copilot, we must enable user authentication (using different supported providers). Of course, when authentication is enabled, we know who is the logged in user interacting with the copilot, but until recently, the credentials used to call those actions was the copilot author’s, and not the former. Therefore, we were very limited from a security perspective, and it was not possible to restrict the use of some actions to a subset of users.
Now it is possible to configure end-user authentication for actions, and we will show you how to do it using the Kimi Quotes custom connector inside a custom copilot.
The Kimi Quotes custom connector
For sample purposes, we are going to use the KimiQuotes API, which returns team radio and interview quotes by Finnish F1 legend Kimi Räikkönen. Our custom connector will use Entra ID authentication, so only specific users will be authorized to use the connector.
First of all, we need to create an App Registration in Azure, and follow the steps mentioned in this very useful article. After that, we can create a custom connector from blank in the maker portal, where we need to define icon, description, host (kimiquotes.pages.dev), and then configure the security section as follows:

Client ID and Client secret values can be found on the app registration in Azure.
Next, we can add different actions to the connector, like the one that gets a random quote:

We still need a couple of steps to have our custom connector ready:
1. In Enterprise Application app properties, we need to set the Assignment Required property to yes, and define which users can use the app (in our case, Ferran and Lisa):

2. In the Security section of the custom connector, the Redirect URL field should have a value (it’s assigned after we save changes for the first time) and we need to add it in the Authentication settings of the app registration.

Finally, we can test that the custom connector works:

Now our custom connector is ready and we will use it in Copilot Studio.
Create an action using end-user authentication
In order to keep it simple, we are going to use the ConversationStart system topic to call the action to get a Kimi Quote:

As soon as we select the action, we need to create a connection to use the connector, but be aware of the message that is also shown in the screen: Users with edit access to this copilot can reuse your connection in other topics of this copilot. You can set up copilot access in Security settings later. This means that if you share the copilot with any other maker to edit it, he or she will be able to use your connection in other topics of the same copilot.

I signed in using my own credentials (Ferran) and then updated the topic to show the quote:

If we look carefully at the connector action properties, we can see that by default, it’s using the currently logged in user credentials.

Therefore, if the user using the copilot has no permissions to use the Kimi Quote connector, an error will be thrown. Let’s check it out!
Using my credentials (Ferran), I can use the copilot and when the conversation starts, the following message is shown:

We need to create or pick up a connection in order to use the action. When we click on the Connect button, a new browser window is opened, requesting the user to create or pick a connection:

Once the connection is created and the action is connected then we can go back to the copilot conversation, and click on the Retry button to get the quote.

What if we are signed in as another user like Sara, who hasn’t got any access to the custom connector? Remember, the connector only allows connections from Ferran and Lisa! An image is worth than a thousand words:

When Sara tries to create a connection, a new window pops-up showing a message that states that she hasn’t got any permissions to do so. It basically means she is not able to use the Kimi Quote action.
She would have the same experience if, for instance, she tries to create a cloud flow in Power Automate using that connector:

Quick reminder (and very important): As we are using a custom connector, remember to share it with all copilot users, no matter they have permissions or not (you can configure those in the Enterprise Application users and groups). We didn’t do it and we were facing some problems until we realize of that. Thanks to Damien Bird from Microsoft for his support on solving this!
On the other hand, if we want all the users to be able to use the action, we could change the end user authentication setting of the action to copilot author authentication. In this sample, the author is a user called Ferran, who has permissions to use the Kimi Quotes custom connector.

Conclusions
The implementation of end user authentication actions in Copilot Studio introduces a robust layer of security that significantly enhances the overall functionality and reliability of copilots. By ensuring that only authenticated users can access and interact with some specific actions, this feature empowers developers to create more powerful and secure copilots. However, to effectively implement these features, it is crucial to be aware of the different configuration settings about connectors, copilot and third-party systems (if that’s the case).
In any case, we would recommend to design topics in a way that non-authorized users don’t need to read those error messages, as it would add confusion more than clarification to them.