auth-wechat-miniprogram

Retrieve verified WeChat Mini Program user identity via CloudBase cloud functions.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/eninem123/hunterclaw --skill auth-wechat-miniprogram-eninem123
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: auth-wechat-miniprogram
Source: https://github.com/eninem123/hunterclaw/tree/main/skills/cloudbase/references/auth-wechat
Command: npx skills add https://github.com/eninem123/hunterclaw --skill auth-wechat-miniprogram-eninem123

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the problem of implementing correct, secure WeChat Mini Program user authentication and retrieving a verified user identity inside CloudBase cloud functions without building complex OAuth flows.

Core Features & Use Cases

  • Mini Program native authentication: Uses CloudBase’s integration so user identity is automatically provided when the Mini Program calls a cloud function.
  • Verified user identity in cloud functions: Retrieves OPENID, APPID, and optionally UNIONID via cloud.getWXContext().
  • Cloud function initialization guidance: Recommends using cloud.DYNAMIC_CURRENT_ENV to reliably bind functions to the correct CloudBase environment.
  • Common use cases: Associate user data by OPENID in your database, implement access control, and optionally support cross-app identification with UNIONID when available.

Quick Start

Use the auth-wechat-miniprogram skill to configure your Mini Program to initialize CloudBase and then call a cloud function that returns the verified OPENID, APPID, and UNIONID (when available).

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 in a WeChat Mini Program cloud function?▼

Use cloud.getWXContext() inside your cloud function after initializing wx-server-sdk with cloud.DYNAMIC_CURRENT_ENV. This returns the verified OPENID and APPID directly from the CloudBase context for backend logic.

Why is UNIONID missing when I call cloud.getWXContext()?▼

UNIONID is conditionally available in cloud.getWXContext() only when the Mini Program is bound to a WeChat Open Platform account. Your cloud function must safely handle cases where UNIONID is undefined for cross-app identification.

What is the best way to authenticate WeChat Mini Program users with CloudBase?▼

Authenticate WeChat Mini Program users with CloudBase by leveraging native integration. Initialize the client, call a cloud function, and automatically receive verified user identity without building custom OAuth flows or manual token handling.

Do I need cloud.DYNAMIC_CURRENT_ENV to initialize wx-server-sdk?▼

Yes, using cloud.DYNAMIC_CURRENT_ENV is recommended for wx-server-sdk initialization. It reliably binds your cloud functions to the correct CloudBase environment, ensuring accurate user identity retrieval and database operations.

Can I use cloud functions for access control in WeChat Mini Programs?▼

Yes, retrieve the verified OPENID via cloud.getWXContext() in your cloud function. Use this identity to associate user data in your CloudBase database and implement secure access control logic for your Mini Program.