auth-wechat-miniprogram

Automate WeChat Mini Program authentication in CloudBase using cloud.getWXContext().

Updated Dec 19, 2025
One-click install
npx skills add https://github.com/yyds-x/walk --skill auth-wechat-miniprogram-yyds-x
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-wechat-miniprogram
Source: https://github.com/yyds-x/walk/tree/main/.agents/skills/cloudbase/references/auth-wechat
Command: npx skills add https://github.com/yyds-x/walk --skill auth-wechat-miniprogram-yyds-x

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

WeChat Mini Program authentication with CloudBase can be complex when integrating identity across cloud functions. This guide provides a clear, step-by-step approach to automatically authenticate users and access WeChat identifiers within CloudBase.

Core Features & Use Cases

  • Native WeChat login with CloudBase and automatic identity provisioning for cloud functions.
  • Access OPENID, APPID, and UNIONID inside cloud functions to implement per-user logic and permissions.
  • Use cases include initializing CloudBase in a Mini Program, retrieving user identity in cloud functions, and calling cloud functions with the user context for secure operations.

Quick Start

Initialize CloudBase in your Mini Program with your env ID and read OPENID, APPID, and UNIONID via cloud.getWXContext() inside cloud functions.

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

To get OPENID and UNIONID in WeChat Mini Program cloud functions, initialize CloudBase using wx.cloud.init with a dynamic environment, then call cloud.getWXContext() inside the cloud function to access user identity context for securing resources.

Why is UNIONID unavailable in my WeChat Mini Program CloudBase cloud function?

UNIONID may be unavailable in WeChat Mini Program CloudBase if the Mini Program is not linked to a WeChat Open Platform account. The authentication mechanism handles cases where UNIONID is absent, relying on OPENID and APPID from cloud.getWXContext() instead.

How do I initialize CloudBase in a WeChat Mini Program for automatic user authentication?

To initialize CloudBase for automatic WeChat Mini Program authentication, call wx.cloud.init with your specific environment ID. This setup provisions user identity automatically, exposing identifiers to cloud functions without manual login flows.

Can I use cloud.getWXContext() to secure CloudBase resources based on WeChat user identity?

Yes, you can use cloud.getWXContext() to secure CloudBase resources. It retrieves the user's OPENID, APPID, and UNIONID within cloud functions, allowing you to implement per-user logic, verify permissions, and personalize experiences securely.

What is the best way to automate WeChat Mini Program authentication across cloud functions?

The best way to automate WeChat Mini Program authentication across cloud functions is using CloudBase native integration. By initializing with wx.cloud.init and reading the context via cloud.getWXContext(), user identity is automatically provisioned for secure operations.

Does WeChat Mini Program CloudBase authentication require manual login code for cloud functions?

No, WeChat Mini Program CloudBase authentication does not require manual login code. By initializing CloudBase with wx.cloud.init, user identifiers like OPENID are automatically exposed to cloud functions via cloud.getWXContext() for seamless identity provisioning.