# Sign-in and keys

Every request to the connector at `https://heymysocial.com/mcp` carries a bearer token. There are two kinds, and both end in the same place: the caller acts as one person, with that person's role in each workspace.

| | Sign-in (OAuth) | Personal key |
|---|---|---|
| For | Assistants with a connector screen: Claude, ChatGPT, Grok on the web, the Gemini app | Command-line assistants and any client that only sends a header |
| The person does | Approves once on a HeyMySocial screen | Creates a key on **Connect your AI** and pastes a command |
| Token | Access token for 8 hours, renewed with a refresh token | `hms_mcp_…`, valid until revoked |
| Ends when | The person disconnects the assistant, or the refresh token runs out | The person revokes the key |

This page is for people building or debugging a client. To connect an assistant, follow [Connect an assistant](https://heymysocial.com/docs/assistant/connect).

## Before anything: a confirmed email

An assistant can only be connected by an account whose email address is confirmed. The consent screen sends an unconfirmed account to the confirmation notice first, and so does the app itself, so **Create a key** cannot be reached until the address is confirmed. Every tool checks again: an unconfirmed account gets `access_denied` with the message "Confirm your email address in HeyMySocial before connecting an assistant."

## Sign-in with OAuth

The connector follows the authorization flow MCP clients expect: OAuth 2.1 authorization code with PKCE, discovery through well-known addresses, and dynamic client registration, so a client needs nothing configured in advance except the connector address.

### Discovery

A request without a valid token is answered `401` with a header that points at the metadata:

```text
WWW-Authenticate: Bearer realm="mcp", resource_metadata="https://heymysocial.com/.well-known/oauth-protected-resource/mcp"
```

The addresses involved:

```text
https://heymysocial.com/.well-known/oauth-protected-resource/mcp
https://heymysocial.com/.well-known/oauth-authorization-server
https://heymysocial.com/oauth/register
https://heymysocial.com/oauth/authorize
https://heymysocial.com/oauth/token
```

The protected resource metadata names the resource and its authorization server:

```json
{
  "resource": "https://heymysocial.com/mcp",
  "authorization_servers": ["https://heymysocial.com"],
  "scopes_supported": ["mcp:use"]
}
```

The authorization server metadata says what the server supports:

```json
{
  "issuer": "https://heymysocial.com",
  "authorization_endpoint": "https://heymysocial.com/oauth/authorize",
  "token_endpoint": "https://heymysocial.com/oauth/token",
  "registration_endpoint": "https://heymysocial.com/oauth/register",
  "response_types_supported": ["code"],
  "code_challenge_methods_supported": ["S256"],
  "scopes_supported": ["mcp:use"],
  "grant_types_supported": ["authorization_code", "refresh_token"],
  "token_endpoint_auth_methods_supported": ["none", "client_secret_basic", "client_secret_post"]
}
```

### Register a client

A client registers itself with a `POST` to the registration endpoint. No authentication is needed.

| Field | Required | Meaning |
|---|---|---|
| `redirect_uris` | yes | 1 to 10 return addresses, each at most 1,024 characters. See which are accepted below. |
| `client_name` | no | The name shown to the person on the consent screen and under their connected assistants, up to 255 characters. `name` is read when `client_name` is absent; with neither, the host of the first return address is used. |
| `logo_uri`, `client_uri` | no | `http` or `https` addresses, up to 2,048 characters. |

```bash
curl -X POST https://heymysocial.com/oauth/register \
  -H "Content-Type: application/json" \
  -d '{"client_name": "My MCP client", "redirect_uris": ["http://localhost:8765/callback"]}'
```

The answer is `201 Created`:

```json
{
  "client_id": "01a21172-c186-791e-9612-81a32f77edc7",
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "redirect_uris": ["http://localhost:8765/callback"],
  "scope": "mcp:use",
  "token_endpoint_auth_method": "none"
}
```

A registered client is public: it gets no secret and must use PKCE. A registration that is not accepted is answered `400` with `error` set to `invalid_redirect_uri` or `invalid_client_metadata` and the reason in `error_description`:

```json
{
  "error": "invalid_redirect_uri",
  "error_description": "redirect_uris.0 is not a permitted redirect domain."
}
```

Registration is limited to 30 requests an hour from one address.

### Which return addresses are accepted

A person who approves a connection is sent back to the client's return address with the authorization code, so the server only registers addresses it can place:

- **A known assistant.** An `https` address that begins with one of the prefixes in the list below. The prefix must match from the start, including the path where one is given.
- **The person's own computer.** An `http` address on `localhost`, `127.0.0.1` or `[::1]`, with any port and any path. This is what a command-line client or a local test client uses.
- **A desktop editor.** An address with the scheme `cursor` or `vscode` and a host, such as `vscode://publisher.extension/callback`.

Anything else is refused: another `https` host, plain `http` on a public host, any other scheme, and any address with a user name or password in it.

```text
https://claude.ai/api/mcp/
https://claude.com/api/mcp/
https://chatgpt.com/
https://grok.com/
https://x.ai/
https://oauth-redirect.googleusercontent.com/r/
https://oauth-redirect.googleusercontent.com/a/
https://oauth-redirect-sandbox.googleusercontent.com/r/
https://oauth-redirect-sandbox.googleusercontent.com/a/
https://oauth-redirect-test.googleusercontent.com/r/
https://oauth-redirect-test.googleusercontent.com/a/
https://antigravity.google/
https://vscode.dev/
https://insiders.vscode.dev/
http://localhost
http://127.0.0.1
cursor://
vscode://
```

The three `googleusercontent.com` hosts are the redirect service the Gemini app's custom apps return through, and `antigravity.google` is the one Google's Antigravity app and command line use. If you are building a client whose return address is not covered, [write to us](https://heymysocial.com/contact) with the address.

### Authorize and get a token

The client sends the person to the authorization endpoint with `response_type=code`, its `client_id`, the `redirect_uri` it registered, a `state`, `scope=mcp:use`, and a PKCE `code_challenge` with `code_challenge_method=S256`.

The person signs in if needed and sees a consent screen. It names the client, the person it will act as and the host they will be sent back to, lists what the assistant will be able to do (read brand facts, research, content, leads and results; create and edit drafts within the person's role; ask for approval) and what it will never do (publish, schedule or send without approval in the app; change an ad budget or spend money; see passwords or credentials). The person presses **Connect** or **Cancel**.

The client then exchanges the code at the token endpoint with `grant_type=authorization_code` and its `code_verifier`, and receives an access token and a refresh token. It sends the access token on every request to the connector:

```text
Authorization: Bearer <access token>
```

### Scopes

| Scope | What it allows |
|---|---|
| `mcp:use` | Work in the person's workspaces: read brand, research, content, leads and results, and prepare drafts for approval. This is the scope the metadata announces and a registered client is given. |
| `social:read` | Read the person's workspaces. A token that holds only this scope is read-only: every tool that changes something answers `access_denied` with "This connection is read-only. Connect again and allow drafting to use this tool." |
| `social:write` | Prepare drafts and updates in the person's workspaces. |

A scope never widens what the person's role allows, and no scope allows publishing, approving or spending. These are scopes of the assistant connector. Workspace API keys for the REST API have their own scopes, described under [API authentication](https://heymysocial.com/docs/api/authentication).

### Token lifetimes

| Token | Lifetime |
|---|---|
| Access token | 8 hours |
| Refresh token | 60 days |

A refresh token works once: using it returns a new access token and a new refresh token, and the old one stops working. There is one exception. The Gemini app stores the first refresh token and does not take a rotated one, so for clients that return through Google's redirect service the refresh token that was used stays valid until it expires. A new one is still issued.

## Personal keys

A personal key is for a client that cannot run a sign-in flow.

- **Format.** `hms_mcp_` followed by 40 random characters.
- **Where it is made.** On [Connect your AI](https://heymysocial.com/connect), with **Create a key**, after picking a command-line assistant or editor. The screen fills the key into the command for that assistant.
- **Shown once.** Only a SHA-256 hash of the key is stored, with its first characters so you can recognise it in the list. A lost key cannot be shown again: revoke it and create another.
- **What it can do.** It acts as the person who created it, in every workspace that person can open, with their role in each. It can do what a signed-in assistant with `mcp:use` can do.
- **How long it lasts.** A key created on the screen has no expiry date. It works until it is revoked.
- **How many.** A person can create at most 10 keys in 10 minutes.

A client sends the key as a bearer token on every request:

```bash
curl -X POST https://heymysocial.com/mcp \
  -H "Authorization: Bearer hms_mcp_…" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'
```

A key that is missing, mistyped or revoked gets the same `401` as any request without a token.

<div class="callout callout-warning"><p class="callout-title">Treat a key like a password</p>

A personal key is not tied to one workspace or one device. Anyone who holds it can work as you in every workspace you can open. Keep it out of shared files and repositories, and revoke it when a machine is retired.

</div>


## Revoking

| What you do | What ends |
|---|---|
| **Disconnect** an assistant on **Connect your AI** | For an assistant that signed in: every access token and refresh token of that client for you, old ones too. For an assistant with a key: that key. |
| **Revoke** a key on **Connect your AI** | That key. |
| Reset your password | Every assistant token, every personal key, every browser session and "remember me". |

A revoked key or token is refused from the next request. Assistants that signed in are also listed under **Account and security**, as "Connected assistants", each with its own **Disconnect** button.

Creating and revoking a key are written to the audit log.

## Rate limit

The connector accepts 90 requests a minute for each signed-in person, counted across all of that person's assistants and keys. Every answer carries `X-RateLimit-Limit` and `X-RateLimit-Remaining`; past the limit the answer is `429` with `Retry-After`.

That is separate from the plan's monthly assistant calls, which are counted per tool call and answered with the error code `quota_exceeded`. See [limits](https://heymysocial.com/docs/assistant#limits).
