auth-wechat-miniprogram

Authenticates WeChat Mini Program users via cloud.getWXContext() in functions.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

WeChat Mini Program authentication with CloudBase provides automatic user identity to cloud functions, simplifying secure access control and user-scoped data operations.

Core Features & Use Cases

  • Automatic identity injection: When a Mini Program calls a cloud function, WeChat provides OPENID, APPID, and UNIONID securely to your backend.
  • Easy environment binding: Use wx.cloud.init with cloud.DYNAMIC_CURRENT_ENV to bind the correct CloudBase environment.
  • Cloud function access: Retrieve identity in cloud functions via cloud.getWXContext() and use OPENID for user-specific logic.
  • Scenarios support: Initialize CloudBase, obtain user identity, call cloud functions from the Mini Program, and perform auth tests.

Quick Start

Initialize CloudBase in your Mini Program and then read the user's identity in cloud functions using cloud.getWXContext.

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 WeChat Mini Program cloud functions?

To get OPENID in WeChat Mini Program cloud functions, call cloud.getWXContext() inside your CloudBase function. WeChat automatically injects the user identity, providing secure access to OPENID, APPID, and UNIONID for user-scoped operations.

How do I initialize CloudBase in a WeChat Mini Program?

Initialize CloudBase in a WeChat Mini Program by calling wx.cloud.init with cloud.DYNAMIC_CURRENT_ENV. This binds the correct CloudBase environment dynamically, enabling seamless cloud function calls and automatic user identity injection.

What is automatic identity injection in WeChat Mini Program authentication?

Automatic identity injection in WeChat Mini Program authentication securely provides OPENID, APPID, and UNIONID to your CloudBase cloud functions. This happens automatically when a Mini Program calls a cloud function, simplifying secure access control.

Do I need wx.cloud to use CloudBase authentication in a Mini Program?

Yes, you need wx.cloud in the Mini Program client to initialize CloudBase and trigger cloud functions. The backend then uses cloud.getWXContext to retrieve the injected identity for authentication and user-specific logic.

Why does my CloudBase environment binding fail in WeChat Mini Program?

CloudBase environment binding fails if you do not use cloud.DYNAMIC_CURRENT_ENV during wx.cloud.init. Setting this dynamic environment variable correctly binds your WeChat Mini Program to the proper CloudBase environment.

Can I use UNIONID for cross-application user identity in WeChat cloud functions?

Yes, you can use UNIONID for cross-application user identity in WeChat cloud functions. The cloud.getWXContext method retrieves UNIONID alongside OPENID and APPID, allowing you to perform unified user-scoped data operations.