auth-wechat-miniprogram

Authenticate WeChat Mini Program users in CloudBase and expose identity to cloud functions.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

CloudBase-powered WeChat Mini Programs often face the challenge of securely authenticating users and reliably accessing their identity within cloud functions. This guide provides a complete, authenticated flow without manual OAuth steps.

Core Features & Use Cases

  • Automatic WeChat identity injection into cloud functions via WeChat Mini Program cloudsdk
  • Retrieve OPENID, APPID, and UNIONID securely for user-specific operations
  • Patterns for initializing CloudBase in Mini Programs, and for calling cloud functions while preserving identity
  • Best practices for storing OPENID and handling UNIONID availability across apps

Quick Start

Initialize CloudBase in the Mini Program and verify user identity by invoking a test cloud function that returns the injected OPENID.

Frequently Asked Questions about auth-wechat-miniprogram

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

FAQPage Schema
How do I authenticate WeChat Mini Program users in CloudBase?

Secure WeChat Mini Program authentication in CloudBase uses wx.cloud in the client and wx-server-sdk in functions to automatically inject user identity, eliminating manual OAuth steps and exposing identity directly to cloud functions.

How do I get OPENID and UNIONID inside a WeChat cloud function?

Retrieve OPENID and UNIONID inside a WeChat cloud function by calling the cloud.getWXContext() method provided by wx-server-sdk, which securely exposes the injected user identity for user-specific operations.

Do I need wx-server-sdk to retrieve WeChat Mini Program user identity in cloud functions?

Yes, you need wx-server-sdk in your cloud functions and wx.cloud in your Mini Program client to securely retrieve user identity like OPENID and APPID through dynamic CloudBase environment initialization.

Why is UNIONID missing when retrieving WeChat user identity in cloud functions?

UNIONID may be missing when retrieving WeChat user identity if the Mini Program is not linked to a WeChat Open Platform account, as UNIONID availability depends on cross-app account configuration.

What's the best way to call cloud functions while preserving WeChat user identity?

The best way to preserve WeChat user identity when calling cloud functions is initializing CloudBase dynamically in the Mini Program client, allowing the cloudsdk to automatically inject identity into the function context.