linkfox-amazon-ads-auth

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Amazon Ads 授权与广告账户管理

Amazon Ads Authorization and Ad Account Management

Amazon Ads 的授权(LWA OAuth)、profile 发现、访问令牌管理。下游 skill 的前置依赖
下游:
linkfox-amazon-ads-entity
(实体查询)、
linkfox-amazon-ads-report
(报告)。
Amazon Ads authorization (LWA OAuth), profile discovery, and access token management. Prerequisite for downstream skills.
Downstream:
linkfox-amazon-ads-entity
(entity query),
linkfox-amazon-ads-report
(reports).

Core Concepts

Core Concepts

  • 授权流程:生成 URL → 用户浏览器授权 → 系统存 token + 同步 profile
  • 一次授权多 profile:每个 marketplace(US/UK/JP…)一个 profileId;下游调用必须带 profileId
  • accountName 必填:调
    authorize_url.py
    前必须问用户要一个非空账号名
  • accessToken 1 小时有效;过期后下游返回 HTTP 401,可用
    refresh_token.py
    续签
  • Authorization Process: Generate URL → User authorizes via browser → System stores token + syncs profiles
  • One Authorization for Multiple Profiles: One profileId per marketplace (US/UK/JP…); downstream calls must include profileId
  • accountName Required: Must ask the user for a non-empty account name before calling
    authorize_url.py
  • accessToken Valid for 1 Hour: After expiration, downstream returns HTTP 401; can renew using
    refresh_token.py

可用脚本

Available Scripts

脚本作用
authorize_url.py
为新账号生成授权 URL(
accountName
必填)
authorized_stores.py
列出已授权的账号 × 站点(按 profileId 聚合)
profiles.py
列 profile 列表(
refresh=true
穿透上游刷新)
refresh_token.py
刷新 accessToken
store_tokens.py
查 token(供下游使用)
入参、响应字段、错误码见
references/api.md
ScriptFunction
authorize_url.py
Generate authorization URL for new accounts (
accountName
required)
authorized_stores.py
List authorized accounts × sites (aggregated by profileId)
profiles.py
List profiles (
refresh=true
triggers upstream refresh)
refresh_token.py
Refresh accessToken
store_tokens.py
Query tokens (for downstream use)
See
references/api.md
for input parameters, response fields, and error codes.

支持区域

Supported Regions

NA
(美加墨巴) /
EU
(英德法意西荷印度中东等) /
FE
(日澳新)。默认
NA
NA
(US, Canada, Mexico, Brazil) /
EU
(UK, Germany, France, Italy, Spain, Netherlands, India, Middle East, etc.) /
FE
(Japan, Australia, New Zealand). Default is
NA
.

Usage Scenarios

Usage Scenarios

1. 新授权账号

1. New Account Authorization

  1. 问用户要
    accountName
    (非空字符串,用于识别)
  2. authorize_url.py
    拿 URL → 给用户在浏览器打开
  3. 授权完成后系统自动存 token + 同步 profile
  4. 可选:调
    authorized_stores.py
    确认
  1. Ask the user for
    accountName
    (non-empty string for identification)
  2. Call
    authorize_url.py
    to get the URL → instruct the user to open it in a browser
  3. After authorization is completed, the system automatically stores the token + syncs profiles
  4. Optional: Call
    authorized_stores.py
    to confirm

2. 列已授权账号

2. List Authorized Accounts

authorized_stores.py
,展示
profileId / accountInfoName / countryCode / region
Call
authorized_stores.py
and display
profileId / accountInfoName / countryCode / region
.

3. 刷新过期令牌

3. Refresh Expired Tokens

下游返回 HTTP 401 或含
expired
/
unauthorized
时,调
refresh_token.py
(传
profileId
authRecordId
)。
When downstream returns HTTP 401 or contains
expired
/
unauthorized
, call
refresh_token.py
(pass
profileId
or
authRecordId
).

4. 给下游解析 profileId(高频)

4. Resolve profileId for Downstream (High Frequency)

用户只说自然语言("美国站"、"我的店铺"),不要让用户报 profileId 数字
用户上下文Agent 动作
只授权 1 个账号
countryCode
直接定位,不问
授权 ≥ 2 个账号 + 只说站点
accountName
向用户澄清
同时给出 accountName + 站点直接定位
显式给出 profileId 数字直接用
站点关键词映射参考(以
authorized_stores
真实
countryCode
兜底):
  • 美国 / US →
    US
    ;英国 / UK →
    UK
    ;日本 / JP →
    JP
    ;德国 / DE →
    DE
静默原则:映射成功时不播报 profileId 数值;仅在歧义或失败时向用户开口。
Users only use natural language ("US site", "my store"), do not ask users to provide the numeric profileId.
User ContextAgent Action
Only one account authorizedDirectly locate by
countryCode
, no need to ask
≥2 accounts authorized + only mentions siteClarify with the user by
accountName
Provides both accountName + siteDirectly locate
Explicitly provides numeric profileIdUse it directly
Site keyword mapping reference (fall back to actual
countryCode
from
authorized_stores
):
  • 美国 / US →
    US
    ; 英国 / UK →
    UK
    ; 日本 / JP →
    JP
    ; 德国 / DE →
    DE
Silent Principle: Do not announce the profileId value when mapping is successful; only communicate with the user in case of ambiguity or failure.

调用原则

Calling Principles

  • 先问
    accountName
    再调
    authorize_url.py
  • 不输出完整 accessToken / refreshToken;脚本已做掩码,不要在摘要里还原
  • 授权失败按错误码解释原因;不擅自重试
  • Ask for
    accountName
    before calling
    authorize_url.py
  • Do not output complete accessToken / refreshToken; scripts have already masked them, do not restore them in summaries
  • Explain the reason for authorization failure based on error codes; do not retry without permission

常见问题

Common Issues

授权链接打开报 400,client_id 看起来被污染

When opening the authorization link, a 400 error occurs and the client_id appears to be corrupted

现象:URL 里
client_id
中间出现空格 /
+
,Amazon 报
StegoRuntimeOAuth2ClientManager:getClientDefinition
。 原因:授权链接 ~270 字符,从终端 / 聊天窗口复制时被软换行插入空格。 解决:
authorize_url.py
成功后会同步写到剪贴板 +
~/.cache/linkfox/last_authorize_url.txt
从这两处复制;浏览器地址栏 Ctrl+V 即可。建议无痕窗口打开。
Symptom: Spaces /
+
appear in the middle of
client_id
in the URL, Amazon reports
StegoRuntimeOAuth2ClientManager:getClientDefinition
. Cause: The authorization link is ~270 characters long, and soft line breaks insert spaces when copied from the terminal / chat window. Solution: After
authorize_url.py
succeeds, the URL is automatically written to the clipboard +
~/.cache/linkfox/last_authorize_url.txt
, copy from these two places; paste directly into the browser address bar using Ctrl+V. It is recommended to open it in an incognito window.

授权回调页显示
profile_sync_failed

Authorization callback page displays
profile_sync_failed

原因:当前 Amazon 账号未在广告后台创建"经理账户(Manager Account)"并关联广告账户。
解决:登录 Amazon Ads 控制台 → Manager accounts → 关联账户,重新授权。
Cause: The current Amazon account has not created a "Manager Account" in the advertising backend and linked it to the ad account.
Solution: Log in to Amazon Ads Console → Manager accounts → Link accounts, then re-authorize.

Not Applicable

Not Applicable

  • 查广告活动 / 组 / 关键词 / 商品广告 / 定向 →
    linkfox-amazon-ads-entity
  • 拉广告报告(含指标) →
    linkfox-amazon-ads-report
  • 修改 / 创建 / 删除广告 → 本系列为只读
  • 店铺订单 / 库存 / 财务 →
    linkfox-amazon-store-*
Feedback:
Auto-detect and report feedback via the Feedback API when any of the following apply:
  1. The functionality or purpose described in this skill does not match actual behavior
  2. The skill's results do not match the user's intent
  3. The user expresses dissatisfaction or praise about this skill
  4. Anything you believe could be improved
Call the feedback API as specified in
references/api.md
. Do not interrupt the user's flow.

For more high-quality, professional cross-border e-commerce skills, visit LinkFox Skills.
  • Query ad campaigns / groups / keywords / product ads / targeting →
    linkfox-amazon-ads-entity
  • Pull ad reports (including metrics) →
    linkfox-amazon-ads-report
  • Modify / create / delete ads → This series is read-only
  • Store orders / inventory / finance →
    linkfox-amazon-store-*
Feedback:
Auto-detect and report feedback via the Feedback API when any of the following apply:
  1. The functionality or purpose described in this skill does not match actual behavior
  2. The skill's results do not match the user's intent
  3. The user expresses dissatisfaction or praise about this skill
  4. Anything you believe could be improved
Call the feedback API as specified in
references/api.md
. Do not interrupt the user's flow.

For more high-quality, professional cross-border e-commerce skills, visit LinkFox Skills.