/pachca:pachca-oauthfrom Pachca
Guides through OAuth 2.0 with PKCE for Pachca: employee authorization flow, consent screen, code exchange, token storage, and revocation. Use when a bot needs per-user tokens.
Ships in Pachca. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
An employee grants a bot their own rights on a consent screen. The bot gets a token per
employee and calls the API as that employee. For your own integration the OAuth client in
Pachca is always a bot: it is the OAuth tab of the bot card. A bot is the app. Two kinds of
client need no registration: the CLI login and MCP clients that sign in through the browser
with a client metadata document. Their tokens live an hour and renew themselves, unlike a bot's
employee token (→ pachca).
invalid_grant,
401 or 403 with an employee token.Not this skill: the bot acting as itself (→ pachca-bots), your own agent connecting to the
MCP server through the browser (→ pachca), a script under your own name (→ pachca-api),
revoking someone's access on the Все токены tab (→ pachca-admin).
| Need | Token | Notes |
|---|---|---|
| Bot posts, reacts to events, works in chats it was added to | Bot token | Sees open conversations and channels with their threads, plus closed chats and threads it is in |
| Agent or headless integration with no employee involved (CI, server, worker) | Bot token | Service account, give it only the scopes the task needs |
| Your own script, one-off export, personal automation | Personal token (Интеграции > API) | You pick the scopes, it does not expire, the value is shown once |
| Working by hand or with an agent on your own machine | CLI login, pachca auth login | Hour-long token that renews itself, scopes = catalog limited by your role |
| Bot needs a specific employee's data or must act as them | Authorized token (this skill) | One per employee, scopes from the bot settings, cut by the employee's role, revocable at any time |
Decide with these questions:
messages:create. Most launches break on these, not on OAuth. An app on the
employee's device (public client) opens the consent link itself, takes the code on its own
redirect address and needs neither: see the
flow reference.client_secret lives.scope parameter in the link is ignored. The employee accepts the whole set or nothing.403 with role_forbidden. A role change applies to the token at once.expires_in. It carries a
refresh_token, but there is nothing to refresh: the token works until it is revoked (by the
employee in Авторизации, by an admin on Все токены, or by the bot itself), OAuth on
the bot is disabled or the bot is deleted. Once the employee is suspended or deleted, calls
return 403 access_denied. A suspended employee's token works again once access is
restored. Making the employee a guest revokes all their tokens: calls return 401.user_id: Игнорировать свои сообщения (ignore_self_messages)
and comparing with the bot's id both let it through. Store the message ids the send returns
and skip those events, or the bot handles its own post as the employee's message.Check this setting with the workspace admin before building anything for regular employees.
oauth_client.scopes explicitly: enabling
OAuth without it requests a broad default set (most, not all, of the scopes a bot can hold),
or, if OAuth was on before, the set saved back then.pachca_get_bot_scopes
(pachca bots list-scopes) lists exactly those. Saving the set refuses bot management
(bots:read, bots:write), drafts (drafts:read, drafts:write) and every owner- or
admin-only scope: users:create, users:update, users:delete, user_status:write,
user_avatar:write, group_tags:write, chat_exports:read, chat_exports:write,
audit_events:read, company_chats:read, company_bots:read. This holds even if only the
owner will ever authorize the bot. So an OAuth bot cannot read or write drafts, manage bots,
invite, edit, suspend or delete employees, manage tags, change someone else's status or
avatar, export messages, read the audit log or list all chats and bots of the workspace. For
those tasks a person uses their own personal token or CLI login:
pachca-messaging).pachca-bots).pachca-admin).pachca-admin).S256 always: required for a public client, recommended for a confidential one.state per button, bind it to the employee you sent the button to, and
accept it once.client_secret to a
browser, mobile or CLI app: choose the public type for those.user_id with the
employee you sent the button to. The button may have been forwarded.401 on an employee token as "access ended": delete the token and send the button
again next time the employee talks to the bot. 403 access_denied (in errors[].code, not
in error) means the employee was suspended or deleted: stop calling with that token and do
not send the button. To tell the cases apart, get the employee with the bot token (scope
users:read): suspended: true means keep the token, it works again once access is
restored; 404 means they were deleted, so delete the token.The exact step order, request fields and error handling: authorization flow.
Only the bot's creator can change it, plus workspace admins if the bot settings give them edit access. In the UI: Интеграции > Боты > Управление, open the bot, tab OAuth, Включить.
Through MCP or CLI, with your own connection (managing bots needs bots:write: your personal
token, CLI login or MCP sign-in can carry it, a bot token never does):
pachca_update_bot (pachca bots update --oauth-client …), or pachca_create_bot at
creation, with the oauth_client object. The consent set is oauth_client.scopes; the
top-level scopes are the rights of the bot's own token. Lists are replaced whole.client_secret comes in the response once: on enabling and on
switching to confidential. Hand it to the user in your reply only, to put into their secret
store.Redirect URI rules:
http is allowed only on the local machine (localhost, 127.0.0.1, [::1]). Every
other web address must be HTTPS. A mobile or desktop app may also use its own scheme in the
com.example.app:/oauth form. No #fragment in any address.redirect_uri in the link must match one in the list exactly. If the listed address has
no query string, query parameters in the link are ignored. If it has one, the link must carry
exactly the same parameters, in any order. For local addresses the port is not compared, so a
desktop or CLI app can use any free port.client_id is not secret: it goes into the link.
pachca_rotate_bot_client_secret,
pachca bots rotate-client-secret): the old secret stops working at once, so have the bot
ready to take the new value first. Issued authorizations and tokens keep working. The new
value is shown once.oauth_client: null): every employee
authorization is revoked and their tokens return 401, the bot leaves the showcase and its
description and screenshots are deleted for good, new authorizations with that client_id
fail. The bot's own tokens keep working. Re-enabling keeps the old client_id and
client_secret (unless rotated), and the showcase needs a new publication. It ends every
employee's authorization at once, so ask first.state values after
a bounded time, for example a day.invalid_grant:
send a new button instead.403 role_forbidden cannot be fixed by re-authorizing. Tell the employee the action is not
available to their role. 403 insufficient_scope can: add the scope to the bot settings and
send the button again.pachca_get_token_info reports on the token of your own connection. To check an
employee token, call token info with that token from the bot's code, or run
pachca oauth token-info in a terminal with that token in PACHCA_TOKEN for that one
command, read from the secret store rather than typed, and without --profile (it overrides
the variable). A value passed with --token stays in shell history and the process list. Do
not export the variable, or later commands run as the employee.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub pachca/openapi --plugin pachca9 skills in this plugin
/pachcaВход в Пачку (Pachca) для агента: подключить агента или MCP-клиента (MCP через браузер или токеном, плагин, CLI), проверить подключение, выбрать токен, разобрать отказ 401/403 инструмента или CLI и отсутствие инструмента (роль, тариф, тип токена, участие в чате). Когда: «подключи Пачку», «настрой MCP Пачки», «войди в Пачку через CLI», «каким токеном подключить агента», «экран входа MCP», «агент получил 403 insufficient_scope», «нет инструмента Пачки (экспорт, журнал аудита)», «что умеет Пачка», "connect Pachca", "set up Pachca MCP", "Pachca CLI login", "which token for my agent or MCP client", "MCP sign-in screen", "MCP tool or CLI returned 401/403", "a Pachca tool is missing". Not for: writing messages → pachca-messaging; search and summaries → pachca-search; administration, who may create tokens → pachca-admin; building a bot → pachca-bots; an agent living in Pachca → pachca-ai-agent; OAuth for employees → pachca-oauth; a token for a script or service, 401/403 in your own code → pachca-api./pachca-adminАдминистрирование пространства Пачки: сотрудники (пригласить, сменить роль, приостановить, удалить), теги и участники чатов, доступ к API и «Все токены», журнал аудита, экспорт, DLP, безопасный контур и шифрование, и что требует владельца, администратора или «Корпорации». Load before a tool call that changes an employee: delete only after a yes to your question. Когда: «пригласи сотрудника», «уволь / удали сотрудника», «сделай администратором», «добавь в тег», «добавь / удали участника чата», «кто в закрытом канале, где я не состою», «доступ к API ограничен», «отзови доступ сотрудника к API», «журнал аудита», «выгрузи переписку», «правило DLP», "invite an employee", "offboard a user", "change role", "add or remove chat members", "let employees create tokens", "export messages". Not for: a missing tool or a general 401/403 → pachca; who is in a tag or chat → pachca-search; writing messages → pachca-messaging; a bot's own token → pachca-bots; an app acting for employees → pachca-oauth; scripts → pachca-api./pachca-ai-agentРешить, бот или MCP, и сделать AI-агента в Пачке в виде бота: его зовут упоминанием в чате или треде либо пишут ему в личный чат, он собирает контекст треда, показывает таймер agent-thinking, отвечает в треде и оформляет длинный ответ карточкой .md. Когда: «AI-агент в Пачке», «агент отвечает по упоминанию в треде», «агент не слышит упоминание», «бот-агент в личных сообщениях», «как агенту собрать контекст треда», «реакция agent-thinking», «длинный ответ агента карточкой .md», «бот или MCP», "AI agent bot in Pachca", "agent replies when mentioned", "agent does not hear a mention", "read thread context", "thinking indicator", "agent reply as an .md card", "bot vs MCP". Not for: working in Pachca from Claude or Cursor through MCP → pachca, pachca-messaging, pachca-search; drafts and scheduled messages (a bot cannot make them), sending a file or report from Claude, Cursor or the CLI → pachca-messaging; webhooks, tokens and settings of any bot → pachca-bots; acting on behalf of an employee → pachca-oauth./pachca-apiAPI Пачки из кода, скриптов и CI: токен и права для скрипта или сервиса, обход всех страниц, ошибки и повторы без дублей (401/403/422, 429, 5xx), файлы в коде, SDK и генератор, CLI в скриптах, массовые выгрузки, поиск метода. Когда: «напиши скрипт для API Пачки», «какой токен дать скрипту, сервису или CI», «мой код получает 401/403/422 от API», «упёрлись в 429», «поиск вернул 504 timeout, повторить?», «обойти все страницы», «скрипт, который выгружает всех сотрудников», «загрузка файла из кода», «SDK Пачки», «какой метод API», "call the Pachca API from code", "token for a script or CI job", "401/403/422 in my code", "cursor pagination", "429 Retry-After", "upload a file from my code", "Pachca SDK", "pachca CLI in CI", "which endpoint". Not for: connecting an agent or MCP client, a 401/403 from an MCP tool → pachca; writing messages, a file to a chat now → pachca-messaging; bots, webhooks, events → pachca-bots; OAuth for employees → pachca-oauth; token policy, all-tokens tab, message export → pachca-admin./pachca-botsБот или интеграция в Пачке: что выбрать (входящий вебхук, бот с событиями, приложение с авторизацией), создание и настройки бота, токены и права, доступ к чатам, приём событий (подпись, повторы, защита от дублей, история событий), кнопки, формы, разворачивание ссылок, витрина. Когда: «сделать бота», «уведомления из CRM или CI в чат», «входящий вебхук», «исходящий вебхук», «бот команд или уведомлений не получает сообщения», «проверить подпись вебхука», «кнопки в сообщении бота», «форма, модальное окно», «превью ссылок, unfurl», «права токена бота», «токен бота утёк», «опубликовать бота в витрине», "build a Pachca bot", "incoming webhook", "outgoing webhook", "bot gets no events", "verify webhook signature", "message buttons", "modal form", "link unfurling", "reissue a leaked bot token". Not for: an AI agent that answers in threads or does not hear a mention → pachca-ai-agent; an app acting for an employee → pachca-oauth; scripts, pagination, 429 → pachca-api; writing messages yourself → pachca-messaging./pachca-messagingПисать в Пачку: разметка, упоминания, куда писать (тред, ответ с цитатой, личный чат), черновик, который отправит сотрудник, пост об изменениях, отложенные и регулярные сообщения в чат, файлы, пересылка, реакции, закрепление, «Важное», правка, удаление, поиск нужного сообщения, когда сначала спросить, лимиты. Когда: «напиши в чат», «отправь сообщение», «ответь в треде», «напиши в личку», «упомяни», «подготовь черновик, я отправлю сам», «напиши пост об изменениях», «запланируй сообщение», «напоминай в канал каждый понедельник», «отправь отчёт файлом .md», «перешли сообщение», «поставь реакцию», «закрепи сообщение», «отметь как важное», «исправь сообщение», "send a message", "reply in the thread", "DM someone", "draft for me to send", "schedule a message", "pin". Not for: search or summaries as the goal, a reminder for an employee → pachca-search; watch a thread, wait for replies → pachca-watch-thread; buttons, forms, clicks → pachca-bots; an AI agent as a bot → pachca-ai-agent; uploads from code → pachca-api.Other plugins' skills for the same job