auth-wechat-miniprogram

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

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/mrpersimmon/xiao-han-studio --skill auth-wechat-miniprogram-mrpersimmon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-wechat-miniprogram
Source: https://github.com/mrpersimmon/xiao-han-studio/tree/main/.agents/skills/cloudbase/references/auth-wechat
Command: npx skills add https://github.com/mrpersimmon/xiao-han-studio --skill auth-wechat-miniprogram-mrpersimmon

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves confusion and errors when implementing WeChat Mini Program authentication in CloudBase, especially around correctly obtaining and trusting user identity values like OPENID and UNIONID.

Core Features & Use Cases

  • Automatic identity injection: explains how WeChat authentication automatically injects verified identity into CloudBase cloud functions.
  • Use OPENID/UNIONID safely: guides how to use OPENID as the primary identifier and when UNIONID is available.
  • Cloud function integration patterns: provides practical guidance for initializing CloudBase, retrieving identity inside a cloud function, and calling a cloud function from the Mini Program.

Quick Start

Use the auth-wechat-miniprogram skill to implement a CloudBase Mini Program flow where a cloud function reads identity via cloud.getWXContext() and returns OPENID/UNIONID to the Mini Program client.

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 using CloudBase?

To get OPENID in a WeChat Mini Program cloud function, initialize wx.cloud and call cloud.getWXContext() to retrieve the verified WeChat Mini Program user identity automatically injected by the CloudBase environment without manual OAuth flows.

Does CloudBase automatically inject WeChat Mini Program user identity into cloud functions?

Yes, CloudBase automatically injects verified WeChat Mini Program user identity into cloud functions. WeChat authentication handles this natively, allowing you to securely access OPENID, APPID, and UNIONID via cloud.getWXContext() as trusted inputs.

What is the difference between OPENID and UNIONID when authenticating WeChat Mini Program users?

OPENID serves as the primary verified identifier for a specific WeChat Mini Program, while UNIONID is available for associating a user across multiple applications under the same WeChat Open Platform account, both retrievable via cloud.getWXContext().

Do I need to build a manual OAuth flow to authenticate WeChat Mini Program users in CloudBase?

No, you do not need to build a manual OAuth flow to authenticate WeChat Mini Program users in CloudBase. The platform automatically injects verified identity into cloud functions, allowing direct retrieval via cloud.getWXContext().

How do I use cloud.DYNAMIC_CURRENT_ENV when retrieving WeChat Mini Program user identity?

Use cloud.DYNAMIC_CURRENT_ENV to initialize the CloudBase environment inside your cloud function, then call cloud.getWXContext() to retrieve verified WeChat Mini Program user identity values like OPENID and UNIONID for user-specific database logic.

Can I trust OPENID and UNIONID as verified inputs for user-specific database association in wx cloud?

Yes, you can trust OPENID and UNIONID as verified inputs for user-specific database association in wx cloud. WeChat authentication automatically injects these verified identity values into CloudBase cloud functions for secure database operations.