auth-wechat-miniprogram

Authenticate WeChat Mini Program users via CloudBase and expose OPENID to cloud functions.

72|5|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/TencentCloudBase/skills --skill auth-wechat-miniprogram
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-wechat-miniprogram
Source: https://github.com/TencentCloudBase/skills/tree/main/skills/auth-wechat
Command: npx skills add https://github.com/TencentCloudBase/skills --skill auth-wechat-miniprogram

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables automatic user identity authentication for WeChat Mini Programs using CloudBase, eliminating manual login steps and making user data available in cloud functions.

Core Features & Use Cases

  • Native WeChat Mini Program authentication with CloudBase, with user identity automatically injected into cloud functions.
  • Access OPENID, APPID, and UNIONID in cloud functions via wx-server-sdk, enabling user-specific operations and secure authorization.
  • Use cases include initializing CloudBase in a Mini Program, extracting user identity in a cloud function, and calling cloud functions from the Mini Program to obtain identity.

Quick Start

  1. In the Mini Program, initialize CloudBase: wx.cloud.init({ env: 'your-env-id', traceUser: true })
  2. In cloud functions, initialize the SDK and read the WeChat identity: const cloud = require('wx-server-sdk'); cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }); const { OPENID, APPID, UNIONID } = cloud.getWXContext()
  3. Call the cloud function from the Mini Program to retrieve identity: wx.cloud.callFunction({ name: 'yourFunction', success: res => console.log(res.result), fail: err => console.error(err) })

Frequently Asked Questions about auth-wechat-miniprogram

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I get OPENID and UNIONID in WeChat Mini Program cloud functions?

To get OPENID and UNIONID in WeChat Mini Program cloud functions, initialize wx-server-sdk and call cloud.getWXContext(), which returns the user identity context automatically injected by CloudBase.

What's the best way to implement automatic WeChat Mini Program authentication with CloudBase?

The best way to implement automatic WeChat Mini Program authentication is using CloudBase with traceUser enabled during wx.cloud.init, eliminating manual login steps and injecting user identity directly into cloud functions.

Do I need wx-server-sdk to authenticate WeChat Mini Program users in cloud functions?

Yes, you need wx-server-sdk to authenticate WeChat Mini Program users in cloud functions, as it provides the cloud.init and cloud.getWXContext methods required to extract OPENID, APPID, and UNIONID.

Why is my WeChat Mini Program user identity not available in cloud functions?

WeChat Mini Program user identity is not available in cloud functions if traceUser is not set to true during wx.cloud.init, preventing CloudBase from automatically injecting the user context into cloud function calls.

Can I access APPID and UNIONID without manual login in a WeChat Mini Program?

Yes, you can access APPID and UNIONID without manual login by initializing CloudBase with traceUser true and calling cloud.getWXContext inside your cloud function to retrieve the injected context.

How does CloudBase automatic user authentication work for WeChat Mini Programs?

CloudBase automatic user authentication works by injecting WeChat Mini Program user identity into cloud function contexts during initialization, allowing cloud.getWXContext to extract OPENID and UNIONID without explicit login flows.