baidu-pan-per-auth-skill

百度网盘OAuth2.0授权码模式,获取/刷新access_token。触发词:百度网盘授权、baidu pan auth、access_token过期、refresh_token刷新、百度网盘token。适用场景:(1)首次授权获取token (2)token过期后刷新 (3)定时刷新token保活。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "baidu-pan-per-auth-skill" with this command: npx skills add ugpoor/baidu-pan-per-auth-skill

百度网盘个人应用授权

前提

已有百度网盘开放平台应用(https://pan.baidu.com/union/doc/al0rwqzzl),.env文件含AppKey和SecretKey。

参考 assets/example.env 创建.env文件,填入实际凭据。

授权流程

首次授权(3步)

Step 1 — 浏览器打开授权页:

https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id={AppKey}&redirect_uri=oob&scope=basic,netdisk&device_id={AppID}

用户登录→点授权→页面显示授权码code(10分钟有效,仅一次)

Step 2 — 换取Token:

python3 scripts/auth.py code <code> </path/to/.env>

成功后.env自动更新AccessToken/RefreshToken/ExpiresIn/Scope/AuthDate

Step 3 — 验证:

curl -s 'https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo&access_token={AccessToken}' -H 'User-Agent: pan.baidu.com'

返回errno=0即有效。

刷新Token(过期后)

access_token有效期30天。过期后用refresh_token刷新:

python3 scripts/auth.py refresh </path/to/.env>

刷新后.env自动更新所有token字段(含新refresh_token)。旧refresh_token立即失效。

定时刷新(推荐)

建议每25天自动刷新,避免token过期。通过cron定时任务实现:

cron add → schedule: {"kind":"every","everyMs":2160000000}(25天)
         → payload.message: "执行百度网盘token刷新:运行 python3 <skill_path>/scripts/auth.py refresh </path/to/.env>,报告结果"
         → sessionTarget: isolated

或用CLI:

openclaw cron add --name "百度网盘token刷新" --every 25d --session isolated \
  --message "执行百度网盘token刷新:运行 python3 <skill_path>/scripts/auth.py refresh </path/to/.env>,报告结果"

关键参数

参数说明
redirect_urioob必须与开放平台配置一致
code有效期10分钟仅一次
access_token有效期30天刷新后旧token失效
refresh_token有效期10年仅一次使用,刷新后返回新refresh_token
scopebasic,netdisk固定值

故障排查

  • error: invalid_grant → code过期或已使用,重新授权
  • error: invalid_refresh_token → refresh_token已用或过期,需重新授权(Step 1)
  • 网络超时 → 国内直连即可,无需代理

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Huo15 Openclaw Enhance

火一五·克劳德·龙虾增强插件 v5.7.8 — 全面适配 openclaw 2026.4.24:peerDep ^4.24 + build/compat 同步到 4.24 + 14 处 api.on 全部去掉 as any 改成 typed hook(hookName 联合类型 + handler 自动推断 Pl...

Registry SourceRecently Updated
General

Content Trend Analyzer

Aggregates and analyzes content trends across platforms to identify hot topics, user intent, content gaps, and generates data-driven article outlines.

Registry SourceRecently Updated
General

Prompt Debugger

Debug prompts that produce unexpected AI outputs — diagnose failure modes, identify ambiguity and conflicting instructions, test variations, compare model re...

Registry SourceRecently Updated
General

Indie Maker News

独行者 Daily - 变现雷达。读对一条新闻,少走一年弯路。每天5分钟,给创业者装上商业雷达。聚焦一人公司、副业、创业变现资讯,智能分类,行动导向。用户下载即能用,无需本地部署!

Registry SourceRecently Updated