> For the complete documentation index, see [llms.txt](https://gdplabs.gitbook.io/glchat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gdplabs.gitbook.io/glchat/application-ui/how-to-guide/chat-input-and-responses/agent-with-user-authentication.md).

# Agent with User Authentication

This guide explains how to create an **agent that requires user authentication** when using tools or MCP connectors.

Currently, this feature is **only supported for tools/MCPs integrated via GL Connectors that enabled within your organization**.

For connector configuration, see: <https://gdplabs.gitbook.io/sdk/gl-ai-agent-package/guides/agents#gl-connectors-token>

***

## Configuration

To enable user authentication, set `user_authentication: true` in the tool or MCP configuration.

{% code title="agents.yaml" %}

```yaml
tool_configs:
  <tool-id>:
    user_authentication: 'true'
    
mcp_configs:
  <mcp-id>:
    user_authentication: 'true'
```

{% endcode %}

<figure><img src="/files/i28Yekv2I1WqFYFehGxj" alt=""><figcaption></figcaption></figure>

When enabled, the agent will require the user to authorize the connector before executing the tool.

***

## How It Works

1. The agent detects which connectors require authentication.
2. If a connector is not authorized, the agent will request authorization.
3. The agent waits until **all required connectors are authenticated**.
4. After authorization is completed, click **Retry** to run the query again.

The agent will then execute the task using the **user's authenticated account**.

***

## Example

Example: **Email Assistant Agent using Gmail**

{% stepper %}
{% step %}

### User request

User asks the agent:

```
Send an email to john@example.com saying the meeting is rescheduled to tomorrow.
```

{% endstep %}

{% step %}

### Connector detection

The agent detects that **Gmail authorization is required**.\
\
Click the Connectors button, it will redirect you to the list of connectors.\
![](/files/HHLQXU3b21EIiqDX4Ck7)
{% endstep %}

{% step %}

### Prompt user

The user is prompted to authorize the Gmail connector.\
Click **Connect** in the required connector and do the authorization.\
![](/files/yMGQ6XYT1d97yIQVmwTM)
{% endstep %}

{% step %}

### Retry

![](/files/QrJwOQJ4OiNAyE3vjjSr)\
After authorization, close the Connectors window and click **Retry** in conversation window.\
![](/files/yKxA0viq8R4nhrG4qfsw)
{% endstep %}

{% step %}

### Execute

The agent sends the email using the **user's Gmail account**.\
![](/files/e1HmOblJTTi7I01mXrjL)

\
![](/files/tA6yeN8H8LOmr34L3ocy)
{% endstep %}
{% endstepper %}

***

{% hint style="info" %}
Notes

* Authentication is required **once per connector** unless the token expires or is revoked.
* If multiple connectors require authentication, **all must be authorized before the agent runs**.
  {% endhint %}
