wechat-auth

wechat-auth is a skill for Claude Code, Codex from guyulong/cn-agent-skills. It costs 18 tokens per session (643 once invoked), scanned A, original, MIT.

An integration guide for WeChat sign-in and authorization across public accounts, Mini Programs, and the Open Platform. It describes exchanging a temporary code for user identifiers and creating a token for later requests.

In plain words
What is it for?
Use it when adding WeChat login, building Mini Program authentication, creating public-account OAuth links, or connecting a Flask backend to WeChat’s login endpoints.
Why use it?
It explains the steps needed to connect a WeChat identity to your own application without treating the login flow as a single front-end action. It also shows how to handle failed login responses.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding WeChat login, building Mini Program authentication, creating public-account OAuth links, or connecting a Flask backend to WeChat’s login endpoints.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/guyulong/cn-agent-skills/wechat-auth
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add guyulong/cn-agent-skills --skill wechat-auth
Clone the repo
git clone --depth 1 https://github.com/guyulong/cn-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for wechat-auth

README.md
[![agentmods](https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/wechat-auth/github.svg)](https://agentmods.dev/skills/guyulong/cn-agent-skills/wechat-auth)
Your own site
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/wechat-auth"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/wechat-auth/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for wechat-auth

Your own site · 80×15
<a href="https://agentmods.dev/skills/guyulong/cn-agent-skills/wechat-auth"><img src="https://agentmods.dev/badge/skills/guyulong/cn-agent-skills/wechat-auth.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 18 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 643 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00018 $0.00643
Opus 5 $0.00009 $0.00321
Sonnet 5 $0.00004 $0.00129
Haiku 4.5 $0.00002 $0.00064

Measured 8d ago against content hash 48f9918aaa29, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

wechat-auth scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

resp = requests.get(url, params=params).json()
skills/wechat-auth/SKILL.md · 92 lines

What it actually says

微信登录授权集成

使用场景

集成微信登录功能,支持公众号、小程序、开放平台三种方式。

小程序登录流程

前端 wx.login() → 获取 code
        ↓
后端用 code 换取 openid/session_key
        ↓
生成自定义 token 返回给前端
        ↓
前端保存 token,后续请求携带

后端代码 (Python/Flask)

import requests

def wx_login(code: str) -> dict:
    """微信小程序登录"""
    url = "https://api.weixin.qq.com/sns/jscode2session"
    params = {
        "appid": APPID,
        "secret": SECRET,
        "js_code": code,
        "grant_type": "authorization_code"
    }
    resp = requests.get(url, params=params).json()
    
    if "errcode" in resp:
        raise ValueError(f"微信登录失败: {resp['errmsg']}")
    
    openid = resp["openid"]
    session_key = resp["session_key"]
    
    # 生成自定义token
    token = generate_token(openid)
    return {"token": token, "openid": openid}

公众号OAuth登录

def get_wechat_auth_url(redirect_uri: str, state: str = "STATE") -> str:
    """获取微信授权URL"""
    return (
        f"https://open.weixin.qq.com/connect/oauth2/authorize"
        f"?appid={APPID}"
        f"&redirect_uri={redirect_uri}"
        f"&response_type=code"
        f"&scope=snsapi_userinfo"
        f"&state={state}"
        f"#wechat_redirect"
    )

def get_wechat_userinfo(code: str) -> dict:
    """通过code获取用户信息"""
    # 1. 获取access_token
    token_url = "https://api.weixin.qq.com/sns/oauth2/access_token"
    token_resp = requests.get(token_url, params={
        "appid": APPID, "secret": SECRET,
        "code": code, "grant_type": "authorization_code"
    }).json()
    
    # 2. 获取用户信息
    user_url = "https://api.weixin.qq.com/sns/userinfo"
    user_resp = requests.get(user_url, params={
        "access_token": token_resp["access_token"],
        "openid": token_resp["openid"],
        "lang": "zh_CN"
    }).json()
    
    return user_resp

安全注意事项

  • session_key 不要返回给前端
  • 不要用 wx.getUserInfo(已废弃),用 wx.getUserProfile
  • 建议使用云函数处理敏感逻辑
  • 定期刷新 access_token
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 92 lines · 18 tokens per session scan A 48f9918aaa29

Subscribe to this mod's changes

wechat-auth is a skill published in the GitHub repository guyulong/cn-agent-skills (3 stars, last pushed 3mo ago), licensed MIT. It adds 18 tokens to every session and 643 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.