> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myego.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Grant scoped access

> Connect a source and hand an agent one scope, then take it back.

This guide grants an agent read access to a single scope on one connected account, and revokes it when the task is done.

<Note>
  Connecting a source works in the app today. The API steps that share a connection
  with an agent are in preview.
</Note>

## Prerequisites

* An ego account with the app running. See the [project README](https://github.com/yasyf/ego) to run it locally.
* The source you want to share. This guide uses a Google account.

## Connect the source

1. Open the app and go to **Integrations**.
2. Select **Connect** on the Google card.
3. Sign in to the Google account and approve only the scopes you intend to share, such as `gmail.readonly`.

The account now shows as `active` in your connections, holding just the scopes you approved. ego stores which account and which scopes; the OAuth tokens stay outside your reach.

## Hand the scope to an agent

Give the agent an API key and the connection it may read. The agent calls the ego API with that key and never sees the underlying token.

```bash theme={null}
curl https://api.myego.dev/api/integrations \
  -H "Authorization: Bearer $EGO_API_KEY"
```

The agent reads through ego from then on, so every request it makes is scoped to that connection and logged.

## Revoke when done

Disconnect the account from **Integrations** in the app. ego revokes the grant at the source and drops the connection, so the key and the agent lose access at once.

## Next steps

<CardGroup cols={2}>
  <Card title="API reference" icon="code" href="/api-reference/introduction">
    The endpoints behind these grants.
  </Card>

  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Make your first request.
  </Card>
</CardGroup>
