auth-wechat-miniprogram

Initialize CloudBase and retrieve OPENID, APPID, and UNIONID via cloud.getWXContext().

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps developers implement native WeChat Mini Program authentication with CloudBase, obtaining user identity in cloud functions and integrating with CloudBase services.

Core Features & Use Cases

  • Native WeChat Mini Program authentication with CloudBase, including automatic user identity injection into cloud functions.
  • Access to user identifiers: OPENID, APPID, and UNIONID (when available) for authorisation and cross-app identity.
  • Cloud function integration: Use cloud.getWXContext() to retrieve identity in server-side code and securely access user data.
  • Use cases include initialization, retrieving user identity in cloud functions, calling cloud functions from Mini Program to get user context, and testing/auth checks.

Quick Start

Initialize CloudBase in the Mini Program using wx.cloud.init with your env ID, and read user identity in cloud functions via 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 a WeChat Mini Program cloud function?

To get OPENID in a WeChat Mini Program cloud function, call cloud.getWXContext() in your server-side code. This retrieves the user identity context injected automatically by CloudBase, including OPENID, APPID, and UNIONID.

How do I initialize CloudBase in a WeChat Mini Program?

Initialize CloudBase in a WeChat Mini Program by calling wx.cloud.init with your specific environment ID. This sets up the connection required to call cloud functions and securely access user data.

Can I retrieve UNIONID using WeChat Mini Program authentication with CloudBase?

Yes, you can retrieve UNIONID using WeChat Mini Program authentication with CloudBase. Access it via cloud.getWXContext() in your cloud function, which provides cross-app identity when available.

What is the best way to expose user identity to cloud functions in WeChat?

The best way to expose user identity to cloud functions in WeChat is using CloudBase. It automatically injects user context into cloud functions, allowing you to securely retrieve identity via cloud.getWXContext().

Do I need cloud.DYNAMIC_CURRENT_ENV to set up WeChat Mini Program authentication?

Yes, initializing with cloud.DYNAMIC_CURRENT_ENV is required for WeChat Mini Program authentication. It ensures your cloud functions correctly resolve the environment context when accessing user identity.

Why does calling a cloud function from my Mini Program fail to return user context?

Calling a cloud function fails to return user context if CloudBase is not initialized properly with wx.cloud.init or if the function does not use cloud.getWXContext() to retrieve the injected user identity.