linkfox-shopee-store-auth
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShopee 店铺授权与管理
Shopee Store Authorization and Management
Shopee Open Platform 的 OAuth 授权、已授权店铺列表、授权状态读取。下游业务的前置依赖(经 调用开放接口)。
/shopee/developerProxyShopee ERP 与 广告(AD) 使用不同应用与 Token,必须按能力分开授权。
OAuth authorization, authorized store list, and authorization status retrieval for Shopee Open Platform. Prerequisite for downstream services (calls open interfaces via ).
/shopee/developerProxyShopee ERP and AD (Advertising) use different applications and Tokens, and must be authorized separately by capability.
Core Concepts
Core Concepts
- 双应用:(商品/订单/物流等,默认)与
appType=erp(站内广告)彼此独立;同店可同时有两条授权appType=ad - 授权流程:生成 URL → 用户浏览器授权 → Shopee 推送 Token → 系统按 落库
state - 店铺标识:与
shopId二选一即可定位;判断是否已授权须同时匹配merchantIdshopId/merchantId + appType - shopName 建议填写:调 前建议问用户要一个便于识别的店铺名(API 非必填)
authorize_url.py - 授权 URL 1 小时有效:每次授权重新调用 ,不要缓存旧地址
authorize_url.py - 下游选店:业务 skill 经 只传
developerProxy/shopId+ path;勿传merchantId,也勿在 proxy 里传accessToken(服务端按 path 自动路由:appType→ AD,其它api/v2/ads/**→ ERP)api/v2/** - accessToken 约 4 小时有效(通常 14400);过期需按对应
expireIn重新授权appType
- Dual Applications: (for products/orders/logistics, default) and
appType=erp(for in-store ads) are independent of each other; a single store can have two authorization records simultaneouslyappType=ad - Authorization Process: Generate URL → User authorizes via browser → Shopee pushes Token → System stores it by
state - Store Identification: Either or
shopIdcan be used to locate a store; to determine if a store is authorized, you must matchmerchantIdshopId/merchantId + appType - shopName is recommended: It is recommended to ask the user for an easily identifiable store name before calling (not required by the API)
authorize_url.py - Authorization URL is valid for 1 hour: Call for each authorization attempt, do not cache old URLs
authorize_url.py - Downstream Store Selection: Business skills only pass /
shopId+ path viamerchantId; do not passdeveloperProxy, and do not passaccessTokenin the proxy (the server automatically routes by path:appType→ AD, otherapi/v2/ads/**→ ERP)api/v2/** - accessToken is valid for approximately 4 hours (usually 14400 seconds for ); if expired, re-authorize according to the corresponding
expireInappType
Shopee authorization routing
Shopee authorization routing
- Use for product, order, logistics, and other ERP authorization.
appType=erp - Use for Shopee Ads authorization.
appType=ad - Treat a missing or blank as
appType.erp - Check authorization by both store identity and ; one store may have separate ERP and AD records.
appType - If the user needs both capabilities, obtain two fresh authorization URLs and explain that both authorizations must be completed.
- Authorization URLs expire after one hour, so obtain a new URL for every authorization attempt.
When calling , pass the Shopee API path plus or . Do not pass or an access token. The service routes through the AD application and all other paths through the ERP application.
developerProxyshopIdmerchantIdappTypeapi/v2/ads/**api/v2/**- Use for product, order, logistics, and other ERP authorization.
appType=erp - Use for Shopee Ads authorization.
appType=ad - Treat a missing or blank as
appType.erp - Check authorization by both store identity and ; one store may have separate ERP and AD records.
appType - If the user needs both capabilities, obtain two fresh authorization URLs and explain that both authorizations must be completed.
- Authorization URLs expire after one hour, so obtain a new URL for every authorization attempt.
When calling , pass the Shopee API path plus or . Do not pass or an access token. The service routes through the AD application and all other paths through the ERP application.
developerProxyshopIdmerchantIdappTypeapi/v2/ads/**api/v2/**可用脚本
Available Scripts
| 脚本 | 作用 |
|---|---|
| 生成授权 URL(可选 |
| 列出已授权店铺(含 |
| 查指定应用的授权/令牌状态(非下游 token 来源;须带 |
入参、响应字段、错误码见 。
references/api.md| Script | Function |
|---|---|
| Generate authorization URL (optional |
| List authorized stores (includes |
| Check authorization/token status for specified applications (not a source of downstream tokens; must pass |
Input parameters, response fields, and error codes can be found in .
references/api.md调用方式
Calling Methods
- API 端点:(完整参数/响应/错误码见
POST /shopee/{authorizeUrl|storeTokens|authorizedStores})references/api.md - Python 脚本:(可用脚本见上文)
python scripts/<脚本名>.py '<JSON 参数>' [--inline] - 成本约束:本工具会消耗积分;失败/空结果不得自动连续试探;需要继续检索时先向用户说明会产生额外消耗。
输出策略(脚本默认行为):
- 始终将完整响应写入 (
<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.json为脚本执行时的工作目录,在 Claude Code 里即当前项目目录;<cwd>取自环境变量<session>,按用户任务自动聚合;禁止写入 /tmp,当前目录不可写则报错)SESSION_ID - 响应体 ≤ 8 KB:落盘后把完整 JSON 打印到 stdout
- 响应体 > 8 KB:落盘后 stdout 只输出摘要(顶层字段、常见计数、最大列表字段的长度 + 前 3 条样本)
- 加 强制全量打印到 stdout(同样落盘)
--inline
读数据建议:先看摘要判断是否足够;需要具体字段时优先用 或 从保存的 json 文件按需抽取,避免整份 JSON 进入上下文。
jqConvertFrom-Json- API Endpoint: (complete parameters/responses/error codes in
POST /shopee/{authorizeUrl|storeTokens|authorizedStores})references/api.md - Python Script: (available scripts listed above)
python scripts/<script-name>.py '<JSON parameters>' [--inline] - Cost Constraints: This tool consumes points; do not automatically retry on failure/empty results; explain to the user that additional consumption will occur before continuing retrieval.
Output Strategy (default script behavior):
- Always write the complete response to (
<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/<skill-name>-<timestamp>.jsonis the working directory when the script is executed, which is the current project directory in Claude Code;<cwd>is taken from the environment variable<session>and automatically aggregated by user tasks; prohibited from writing to /tmp, report an error if the current directory is not writable)SESSION_ID - Response body ≤ 8 KB: Print the full JSON to stdout after saving to disk
- Response body > 8 KB: Print only a summary (top-level fields, common counts, length of the largest list field + first 3 samples) to stdout after saving to disk
- Add to force full printing to stdout (still saves to disk)
--inline
Data Reading Suggestion: First check the summary to see if it is sufficient; when specific fields are needed, prefer to extract from the saved JSON file using or as needed, avoid loading the entire JSON into context.
jqConvertFrom-Json解决认证和积分问题
Resolving Authentication and Points Issues
发生以下异常情况时,采用 references/onboarding.md 引导解决问题:
For the following abnormal situations, guide users to resolve them using references/onboarding.md:
异常情况
Abnormal Situations
- 未配置API Key:环境变量未配置 ,也未配置
LINKFOX_AGENT_API_KEY。LINKFOXAGENT_API_KEY - 响应401或402状态码
- 响应提示积分或余额不足:消息含"积分余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值",或类似含义的内容。
- API Key not configured: The environment variable or
LINKFOX_AGENT_API_KEYis not configured.LINKFOXAGENT_API_KEY - Response returns 401 or 402 status code
- Response indicates insufficient points or balance: Messages contain "insufficient points balance/insufficient billing/insufficient balance/quota exceeded/insufficient balance/package expired/need to recharge/please recharge", or similar meanings.
支持区域
Supported Regions
cnglobalbrcncnglobalbrcnUsage Scenarios
Usage Scenarios
1. 新授权店铺(ERP,默认)
1. New Store Authorization (ERP, Default)
- 建议问用户要 (便于后续识别;API 非必填)
shopName - 确认 (默认
region;全球站cn,巴西global)br - 调 ,传
authorize_url.py(或不传,服务端默认 erp)→ 给用户在浏览器打开(安全警告:为保障店铺安全,请务必在日常运营该店铺的安全网络环境中打开此链接。强烈建议使用紫鸟浏览器等专业的防关联浏览器进行授权,切勿在陌生或公共网络下操作。)appType=erp - 授权完成后系统自动存 token;浏览器跳转成功/失败页
- 调 ,确认存在
authorized_stores.py(或空,历史记录视为 erp)的记录appType=erp
- It is recommended to ask the user for (for easy identification later; not required by the API)
shopName - Confirm (default
region;cnfor global sites,globalfor Brazil)br - Call with
authorize_url.py(or omit, server defaults to erp) → Ask the user to open it in a browser (Security Warning: To ensure store security, please open this link in a secure network environment where you usually operate the store. It is strongly recommended to use professional anti-association browsers like Purple Bird Browser for authorization, do not operate in unfamiliar or public networks.)appType=erp - The system automatically saves the token after authorization is completed; the browser redirects to a success/failure page
- Call to confirm there is a record with
authorized_stores.py(or empty, historical records are treated as erp)appType=erp
2. 广告应用授权(AD)
2. Advertising Application Authorization (AD)
- 调 ,检查目标店是否已有
authorized_stores.pyappType=ad - 未授权时调 ,传
authorize_url.py,并明确告知用户这是广告应用授权(与 ERP 无关)appType=ad - 授权完成后再次检查
appType=ad - 禁止用 ERP 授权代替广告授权
- Call to check if the target store already has
authorized_stores.pyappType=ad - If not authorized, call with
authorize_url.py, and clearly inform the user that this is advertising application authorization (unrelated to ERP)appType=ad - Check again after authorization is completed
appType=ad - Prohibit using ERP authorization instead of advertising authorization
3. 同时需要 ERP 与广告
3. Need Both ERP and Advertising Authorization
- 分别检查 与
appType=erpappType=ad - 仅为缺失的应用生成授权地址;两项都缺则生成两个 URL,并标注用途
- 提示用户需分别打开并完成两次授权;一次授权不会覆盖另一项能力
- Check and
appType=erprespectivelyappType=ad - Generate authorization URLs only for missing applications; if both are missing, generate two URLs and label their purposes
- Prompt the user to open and complete the two authorizations separately; one authorization will not cover the other capability
4. 列已授权店铺
4. List Authorized Stores
调 ,展示 。同店可能出现 ERP、AD 两条。
authorized_stores.pyshopName / shopId / merchantId / region / **appType**Call to display . A single store may have two entries for ERP and AD.
authorized_stores.pyshopName / shopId / merchantId / region / **appType**5. 给下游准备店铺选店信息(高频)
5. Prepare Store Selection Information for Downstream Services (High Frequency)
用户只说自然语言("我的虾皮店"、"67890 那家店"),不要让用户报冗长 token。
| 用户上下文 | Agent 动作 |
|---|---|
| 只授权 1 家店铺(且目标能力已授权) | 直接取该店铺 |
| 授权 ≥ 2 家 + 只说店名 | 按 |
| 同时给出 shopName 或 shopId | 直接定位 |
| 显式给出 shopId / merchantId | 直接用 |
店铺在列表中存在但缺少目标 | 按能力发起对应授权,不要调用业务接口 |
静默原则:定位成功时只确认店铺标识与应用类型,不向用户索要 token。
推荐流程: 按 确认已授权 → 下游 skill 直接 传入 (或 ),由服务端按 path 解析对应应用 token。
authorized_stores.pyshopId + appTypePOST /shopee/developerProxyshopIdmerchantIdstore_tokens.pyappTypeaccessTokenUsers only use natural language ("my Shopee store", "store 67890"), do not ask users to provide lengthy tokens.
| User Context | Agent Action |
|---|---|
| Only 1 store is authorized (and the target capability is already authorized) | Directly retrieve the store's |
| ≥2 stores authorized + only mentions store name | Clarify with the user based on |
| Provides both shopName or shopId | Locate directly |
| Explicitly provides shopId / merchantId | Use directly |
Store exists in the list but lacks the target | Initiate corresponding authorization for the capability, do not call business interfaces |
Silence Principle: When positioning is successful, only confirm the store identifier and application type, do not ask the user for a token.
Recommended Process: confirms authorization by → Downstream skills directly with (or ), and the server parses the corresponding application token by path.
authorized_stores.pyshopId + appTypePOST /shopee/developerProxyshopIdmerchantIdstore_tokens.pyappTypeaccessToken调用原则
Calling Principles
- 授权前建议确认 、
shopName、regionappType - 不假设 响应含 raw
storeTokens;展示状态与过期元数据即可accessToken - 授权失败按错误码解释原因;不擅自重试
- 令牌过期须按对应 重新走授权流程
appType - 历史空 视为 ERP,不是 AD
app_type
- It is recommended to confirm ,
shopName, andregionbefore authorizationappType - Do not assume that the response contains raw
storeTokens; only display status and expiration metadataaccessToken - Explain the reason for authorization failure based on error codes; do not retry without permission
- If the token expires, re-initiate the authorization process according to the corresponding
appType - Historical empty is treated as ERP, not AD
app_type
常见问题
Common Issues
授权完成但查不到店铺
Authorization Completed but Store Not Found
原因:Token 推送回调()未成功落库,或 不匹配。
解决:查看服务日志;重新调 (勿复用过期 URL)完成授权。
/shopee/oauth/tokenCallbackstateauthorize_url.pyCause: Token push callback () failed to save to the database, or does not match.
Solution: Check service logs; re-call (do not reuse expired URLs) to complete authorization.
/shopee/oauth/tokenCallbackstateauthorize_url.py查令牌 / 业务调用返回 1004
Token Query / Business Call Returns 1004
原因: / 错误,或目标应用未授权(例如只有 ERP、没有 AD)。
解决:先调 核对 ;缺则按能力重新授权。
shopIdmerchantIdauthorized_stores.pyshopId + appTypeCause: Incorrect / , or the target application is not authorized (e.g., only ERP is authorized, no AD).
Solution: First call to verify ; re-authorize for the missing capability if needed.
shopIdmerchantIdauthorized_stores.pyshopId + appType店铺已授权但广告 API 失败
Store Authorized but Advertising API Fails
原因:有 ERP 记录 ≠ 有 AD 记录;广告不能使用 ERP Token。
解决:发起 授权后再调 。
appType=adlinkfox-shopee-store-adsCause: Having an ERP record ≠ having an AD record; advertising cannot use ERP Token.
Solution: Initiate authorization before calling .
appType=adlinkfox-shopee-store-adsNot Applicable
Not Applicable
- Shopee 订单查询与处理 →
linkfox-shopee-store-orders - Shopee 店铺信息与设置 →
linkfox-shopee-store-shop - Shopee 店铺商品 listing →
linkfox-shopee-store-product - Shopee 跨境全球商品 GlobalProduct →
linkfox-shopee-store-global-product - Shopee 跨境商户信息 Merchant →
linkfox-shopee-store-merchant - Shopee 物流发货 Logistics →
linkfox-shopee-store-logistics - Shopee 退货退款 Returns →
linkfox-shopee-store-returns - Shopee 站内广告 Ads → (业务调用;授权仍用本 skill 的
linkfox-shopee-store-ads)appType=ad - Shopee 支付结算 Payment →
linkfox-shopee-store-payment - Shopee 联盟营销 AMS →
linkfox-shopee-store-ams - Shopee 店铺视频 Video →
linkfox-shopee-store-video - Shopee 媒体上传 MediaSpace →
linkfox-shopee-store-media-space - Shopee 媒体上传 Media → (
linkfox-shopee-store-media,module=130)api/v2/media/... - Shopee 头程物流 FirstMile →
linkfox-shopee-store-first-mile - Shopee 折扣促销 Discount →
linkfox-shopee-store-discount - Shopee 套装优惠 Bundle Deal →
linkfox-shopee-store-bundle-deal - Shopee 加购优惠 Add-On Deal →
linkfox-shopee-store-add-on-deal - Shopee 店铺优惠券 Voucher →
linkfox-shopee-store-voucher - Shopee 店铺秒杀 Shop Flash Sale →
linkfox-shopee-store-shop-flash-sale - Shopee 关注有礼 Follow Prize →
linkfox-shopee-store-follow-prize - Shopee 精选商品 Top Picks →
linkfox-shopee-store-top-picks - Shopee 店铺分类 Shop Category →
linkfox-shopee-store-shop-category - Shopee 账户健康 Account Health →
linkfox-shopee-store-account-health - Shopee Public 公共模块 → (
linkfox-shopee-store-public底层 OAuth / Partner 查询)v2.public.* - Shopee Push 推送机制 →
linkfox-shopee-store-push - Shopee SBS 仓储服务 →
linkfox-shopee-store-sbs - Shopee FBS 巴西仓储 →
linkfox-shopee-store-fbs - Shopee 直播 Livestream →
linkfox-shopee-store-livestream - Shopee 选品(友鹰) →
linkfox-youying-shopee-product-search - 商品 listing 管理 → 专用 product skill 或 商品 API
developerProxy
- Shopee Order Query and Processing →
linkfox-shopee-store-orders - Shopee Store Information and Settings →
linkfox-shopee-store-shop - Shopee Store Product Listing →
linkfox-shopee-store-product - Shopee Cross-border Global Product GlobalProduct →
linkfox-shopee-store-global-product - Shopee Cross-border Merchant Information Merchant →
linkfox-shopee-store-merchant - Shopee Logistics Shipment →
linkfox-shopee-store-logistics - Shopee Return and Refund →
linkfox-shopee-store-returns - Shopee In-store Ads → (business calls; authorization still uses this skill's
linkfox-shopee-store-ads)appType=ad - Shopee Payment Settlement →
linkfox-shopee-store-payment - Shopee Affiliate Marketing AMS →
linkfox-shopee-store-ams - Shopee Store Video →
linkfox-shopee-store-video - Shopee Media Upload MediaSpace →
linkfox-shopee-store-media-space - Shopee Media Upload Media → (
linkfox-shopee-store-media, module=130)api/v2/media/... - Shopee First Mile Logistics →
linkfox-shopee-store-first-mile - Shopee Discount Promotion →
linkfox-shopee-store-discount - Shopee Bundle Deal →
linkfox-shopee-store-bundle-deal - Shopee Add-On Deal →
linkfox-shopee-store-add-on-deal - Shopee Store Voucher →
linkfox-shopee-store-voucher - Shopee Store Flash Sale →
linkfox-shopee-store-shop-flash-sale - Shopee Follow Prize →
linkfox-shopee-store-follow-prize - Shopee Top Picks →
linkfox-shopee-store-top-picks - Shopee Store Category →
linkfox-shopee-store-shop-category - Shopee Account Health →
linkfox-shopee-store-account-health - Shopee Public Module → (underlying OAuth / Partner query for
linkfox-shopee-store-public)v2.public.* - Shopee Push Mechanism →
linkfox-shopee-store-push - Shopee SBS Warehousing Service →
linkfox-shopee-store-sbs - Shopee FBS Brazil Warehousing →
linkfox-shopee-store-fbs - Shopee Livestream →
linkfox-shopee-store-livestream - Shopee Product Selection (Youying) →
linkfox-youying-shopee-product-search - Product listing management → Use dedicated product skill or product API
developerProxy
积分消耗规则
Points Consumption Rules
不消耗积分。
Feedback:
Auto-detect and report feedback via the Feedback API when any of the following apply:
- The functionality or purpose described in this skill does not match actual behavior
- The skill's results do not match the user's intent
- The user expresses dissatisfaction or praise about this skill
- Anything you believe could be improved
Call the feedback API as specified in . Do not interrupt the user's flow.
references/api.mdFor more high-quality, professional cross-border e-commerce skills, visit LinkFox Skills.
No points are consumed.
Feedback:
Auto-detect and report feedback via the Feedback API when any of the following apply:
- The functionality or purpose described in this skill does not match actual behavior
- The skill's results do not match the user's intent
- The user expresses dissatisfaction or praise about this skill
- Anything you believe could be improved
Call the feedback API as specified in . Do not interrupt the user's flow.
references/api.mdFor more high-quality, professional cross-border e-commerce skills, visit LinkFox Skills.