Token导航 LogoToken导航

Agent Skill · 开发

auth-wechat-miniprogram(授权微信小程序)

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

auth-wechat-miniprogram 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证为 MIT,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 12,732。

总安装 1,151周安装 47GitHub Stars 997下载 372核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:auth-wechat-miniprogram(授权微信小程序)
来源仓库:https://github.com/tencentcloudbase/cloudbase-mcp
仓库路径:skills/auth-wechat-miniprogram
安装命令:
npx skills add https://github.com/tencentcloudbase/cloudbase-mcp --skill auth-wechat-miniprogram
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/tencentcloudbase/cloudbase-mcp --skill auth-wechat-miniprogram

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

auth-wechat-miniprogram 用于微信小程序的 CloudBase 认证集成,支持自动登录和用户身份验证。适用于小程序开发中的身份识别和授权管理场景。

通过 github 安装并使用 npx skills add https://github.com/tencentcloudbase/cloudbase-mcp --skill auth-wechat-miniprogram 命令部署。使用时需注意微信生态的安全机制,避免与其他系统集成时产生冲突。

建议结合来源仓库和原始 README 文档进一步核验具体用法和功能边界。

来源仓库内路径:skills/auth-wechat-miniprogram

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/tencentcloudbase/cloudbase-mcp --skill auth-we…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

auth-wechat-miniprogram 怎么安装?

在终端执行 npx skills add https://github.com/tencentcloudbase/cloudbase-mcp --skill auth-wechat-minip…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

auth-wechat-miniprogram 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

auth-wechat-miniprogram 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

auth-wechat-miniprogram 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

auth-wechat-miniprogram 用的人多吗?

公开数据是累计安装 1,151 次,近一周安装 47 次,下载 372 次,GitHub 997 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

auth-wechat-miniprogram 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
auth-wechat-miniprogram

授权微信小程序 · 本页

1,151997调用外部服务MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

When to use this skill

Use this skill for WeChat Mini Program (小程序) authentication in a CloudBase project.

Use it when you need to:

  • Implement WeChat Mini Program login with CloudBase
  • Access user identity (openid, unionid) in cloud functions
  • Understand how WeChat authentication integrates with CloudBase
  • Build Mini Program features that require user identification

Key advantage: WeChat Mini Program authentication with CloudBase is seamless and automatic - no complex OAuth flows needed. When a Mini Program calls a cloud function, the user's openid is automatically injected and verified by WeChat.

Do NOT use for:

  • Web-based WeChat login (use the auth-web skill)
  • Server-side auth with Node SDK (use the auth-nodejs skill)
  • Non-WeChat authentication methods (use appropriate auth skills)

How to use this skill (for a coding agent)

  1. Confirm CloudBase environment

- Ask the user for: - env – CloudBase environment ID - Confirm the Mini Program is linked to the CloudBase environment

  1. Understand the authentication flow

- WeChat Mini Program authentication is native and automatic - No explicit login API calls needed in most cases - User identity is automatically available in cloud functions - CloudBase handles all authentication verification

  1. Pick a scenario from this file

- For basic user identity in cloud functions, use Scenario 2 - For Mini Program initialization, use Scenario 1 - For calling a cloud function from the Mini Program and receiving user identity, use Scenario 3 - For testing authentication, use Scenario 4

  1. Follow CloudBase API shapes exactly

- Use wx-server-sdk in cloud functions - Use wx.cloud in Mini Program client code - Treat method names and parameter shapes in this file as canonical

  1. If you're unsure about an API

- Consult the official CloudBase Mini Program documentation - Only use methods that appear in official documentation


Core concepts

How WeChat Mini Program authentication works with CloudBase

  1. Automatic authentication:

- When a Mini Program user calls a cloud function, WeChat automatically injects the user's identity - No need for complex OAuth flows or token management - CloudBase verifies the authenticity of the identity

  1. User identifiers:

- OPENID – Unique identifier for the user in this specific Mini Program - APPID – The Mini Program's App ID - UNIONID – (Optional) Unique identifier across all apps under the same WeChat Open Platform account - Only available when the Mini Program is bound to a WeChat Open Platform account - Useful for identifying the same user across multiple Mini Programs or Official Accounts

  1. Security:

- The openid, appid, and unionid are verified and trustworthy - WeChat has already completed authentication - Developers can directly use these identifiers without additional verification

  1. No explicit login required:

- Users are automatically authenticated when they use the Mini Program - No need to call login APIs in most cases - Identity is available immediately in cloud functions


Scenarios – WeChat Mini Program auth patterns

Scenario 1: Initialize CloudBase in Mini Program

Use this in your Mini Program's app.js or entry point:

// app.js
App({
  onLaunch: function () {
    // Initialize CloudBase
    wx.cloud.init({
      env: 'your-env-id',  // Your CloudBase environment ID
      traceUser: true      // Optional: track user access in console
    })
  }
})

Key points:

  • Call wx.cloud.init() once when the Mini Program launches
  • Set env to your CloudBase environment ID
  • traceUser: true enables user access tracking in CloudBase console (optional but recommended)

Scenario 2: Get user identity in a cloud function

Use this when you need to know who is calling your cloud function:

// Cloud function: cloudfunctions/getUserInfo/index.js
const cloud = require('wx-server-sdk')

// Initialize cloud with dynamic environment
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

exports.main = async (event, context) => {
  // Get user identity - this is automatically injected by WeChat
  const { OPENID, APPID, UNIONID } = cloud.getWXContext()

  console.log('User identity:', { OPENID, APPID, UNIONID })

  // Use OPENID for user-specific operations
  // For example: query user data, check permissions, etc.

  return {
    openid: OPENID,
    appid: APPID,
    unionid: UNIONID  // May be undefined if not available
  }
}

Key points:

  • Use cloud.getWXContext() to get user identity
  • OPENID is always available and uniquely identifies the user
  • APPID identifies the Mini Program
  • UNIONID is only available when:

- The Mini Program is bound to a WeChat Open Platform account - The user has authorized the Mini Program

  • These values are verified and trustworthy - no need to validate them
  • Use cloud.DYNAMIC_CURRENT_ENV to automatically use the current environment

Best practices:

  • Store OPENID in your database to associate data with users
  • Use OPENID for authorization and access control
  • Use UNIONID when you need to identify users across multiple Mini Programs or Official Accounts
  • Never expose OPENID to other users (it's a private identifier)

Scenario 3: Call cloud function from Mini Program

Use this in your Mini Program to call a cloud function and get user identity:

// In Mini Program page
Page({
  onLoad: function() {
    this.getUserInfo()
  },

  getUserInfo: function() {
    wx.cloud.callFunction({
      name: 'getUserInfo',  // Cloud function name
      data: {},             // Optional parameters
      success: res => {
        console.log('User info from cloud function:', res.result)
        // res.result contains { openid, appid, unionid }

        // Use the user info
        this.setData({
          openid: res.result.openid
        })
      },
      fail: err => {
        console.error('Failed to get user info:', err)
      }
    })
  }
})

Key points:

  • Use wx.cloud.callFunction() to call cloud functions
  • User identity is automatically passed to the cloud function
  • No need to manually send user credentials
  • Handle both success and error cases

Scenario 4: Test authentication - Simple test function

Cloud function (cloudfunctions/test/index.js):

const cloud = require('wx-server-sdk')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

exports.main = async (event, context) => {
  // Get verified user identity - automatically injected by WeChat
  const { OPENID, APPID, UNIONID } = cloud.getWXContext()

  console.log('User identity:', { OPENID, APPID, UNIONID })

  return {
    success: true,
    message: 'Authentication successful',
    identity: {
      openid: OPENID,
      appid: APPID,
      unionid: UNIONID || 'Not available'
    },
    timestamp: new Date().toISOString()
  }
}

Mini Program code:

// pages/index/index.js
Page({
  data: {
    userIdentity: null
  },

  onLoad: function() {
    this.testAuth()
  },

  testAuth: function() {
    console.log('Testing authentication...')

    wx.cloud.callFunction({
      name: 'test',
      success: res => {
        console.log('Authentication test result:', res.result)

        this.setData({
          userIdentity: res.result.identity
        })

        wx.showToast({
          title: 'Auth successful',
          icon: 'success'
        })
      },
      fail: err => {
        console.error('Authentication test failed:', err)
        wx.showToast({
          title: 'Auth failed',
          icon: 'error'
        })
      }
    })
  }
})

Key points:

  • No explicit login API call needed
  • User identity is automatically available in cloud function
  • OPENID is always present and verified
  • UNIONID may be undefined if not available
  • Use this pattern to verify authentication is working correctly

Best practices

1. Always use cloud.DYNAMIC_CURRENT_ENV

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

This ensures the cloud function uses the correct environment automatically.

2. Store OPENID for user identification

  • Use OPENID as the primary user identifier
  • Store it in your database to associate data with users
  • Never expose OPENID to other users

3. Handle UNIONID availability

const { OPENID, UNIONID } = cloud.getWXContext()

if (UNIONID) {
  // User has UNIONID - can be used for cross-app identification
  console.log('UNIONID available:', UNIONID)
} else {
  // UNIONID not available - use OPENID only
  console.log('Using OPENID only:', OPENID)
}

4. Use OPENID for user-specific operations

  • Use OPENID to identify and authorize users
  • Store OPENID when you need to associate data with users
  • Use OPENID in queries to ensure users only access their own data

5. Error handling

Always handle errors when calling cloud functions:

wx.cloud.callFunction({
  name: 'myFunction',
  success: res => {
    // Handle success
  },
  fail: err => {
    console.error('Cloud function error:', err)
    // Show user-friendly error message
    wx.showToast({
      title: 'Operation failed',
      icon: 'error'
    })
  }
})

6. Initialize CloudBase early

Initialize CloudBase in app.js onLaunch:

App({
  onLaunch: function () {
    wx.cloud.init({
      env: 'your-env-id',
      traceUser: true
    })
  }
})

Common patterns

Pattern 1: Get and return user identity

const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

exports.main = async (event, context) => {
  const { OPENID, APPID, UNIONID } = cloud.getWXContext()

  return {
    openid: OPENID,
    appid: APPID,
    unionid: UNIONID || null
  }
}

Pattern 2: Use OPENID for authorization

const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

exports.main = async (event, context) => {
  const { OPENID } = cloud.getWXContext()

  // Check if user is authorized
  if (OPENID === event.resourceOwnerId) {
    // User is authorized to access this resource
    return { authorized: true }
  } else {
    return { authorized: false, error: 'Unauthorized' }
  }
}

Pattern 3: Handle UNIONID availability

const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

exports.main = async (event, context) => {
  const { OPENID, UNIONID } = cloud.getWXContext()

  if (UNIONID) {
    // Can use UNIONID for cross-app user identification
    console.log('User has UNIONID:', UNIONID)
  } else {
    // Fall back to OPENID only
    console.log('Using OPENID only:', OPENID)
  }

  return { openid: OPENID, hasUnionId: !!UNIONID }
}

Summary

WeChat Mini Program authentication with CloudBase is simple and secure:

  1. No explicit login needed - authentication is automatic
  2. User identity is verified - OPENID, APPID, and UNIONID are trustworthy
  3. Easy to use - just call cloud.getWXContext() in cloud functions
  4. Secure by default - WeChat handles all authentication verification

Key takeaways:

  • Initialize CloudBase with wx.cloud.init() in Mini Program
  • Use cloud.getWXContext() to get user identity in cloud functions
  • Use OPENID for user identification and authorization
  • Handle UNIONID availability appropriately
  • No explicit login API calls needed - authentication is automatic

For more complex authentication scenarios or integration with other systems, consider using CloudBase custom login in combination with WeChat authentication.

平台分布

Claude Code

30.83%
按下载量换算115

Antigravity

21.74%
按下载量换算81

trae

18.36%
按下载量换算68

Codex

13.51%
按下载量换算50

OpenCode

7.21%
按下载量换算27

Gemini CLI

3.1%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills