WeChat Enhanced icon

WeChat Enhanced

WeChat Enhanced Node - Suporte completo para Mini Programs, Official Accounts, WeChat Pay e WeChat Work

Overview

The node "WeChat Enhanced" provides comprehensive integration with various WeChat services, including Mini Programs, Official Accounts, WeChat Pay, WeChat Work, and others. Specifically, for the Mini Program resource and the Code to Session operation, this node exchanges a WeChat login code for session information. This is typically used in authentication flows where a user logs into a Mini Program, and the backend needs to validate the login code to obtain session details such as the user's OpenID and session key.

Common scenarios:

  • Authenticating users in a WeChat Mini Program by exchanging the temporary login code for session credentials.
  • Retrieving session info to maintain user sessions or personalize user experiences.
  • Backend validation of WeChat login codes during user sign-in processes.

Practical example:
A developer building a Mini Program wants to authenticate users securely. When a user logs in on the client side, the Mini Program obtains a login code. The developer uses this node to send that code to WeChat's API and retrieve session data, which can then be used to identify the user and manage their session on the server.


Properties

Name Meaning
Code The WeChat login code obtained from the Mini Program client after user login. It is required to exchange for session information.

Output

The output JSON contains the session information returned by the WeChat API when exchanging the login code. This typically includes:

  • openid: The unique identifier for the user within the Mini Program.
  • session_key: A session key used for encrypting/decrypting user data.
  • Possibly other fields like unionid if the user has linked accounts.

The exact structure depends on WeChat's response but generally provides all necessary session credentials for further authenticated interactions.

This node does not output binary data for this operation.


Dependencies

  • Requires an API key credential for the external "N8N Tools API" service, which acts as a proxy or helper for calling WeChat APIs.
  • The node validates the subscription and API key before making requests.
  • The node depends on an internal helper class (WeChatApi) that handles communication with WeChat endpoints.
  • No direct environment variables are mentioned, but proper configuration of the API key credential is necessary.

Troubleshooting

  • Invalid subscription or API key error: If the node throws an error about invalid subscription or API key, verify that the API key credential is correctly configured and active.
  • Unsupported operation error: If the operation name is incorrect or unsupported, ensure the operation is set exactly to "code2Session" under the Mini Program resource.
  • Missing or invalid code parameter: The "Code" property is required; ensure it is provided and valid (i.e., obtained freshly from the Mini Program client).
  • Network or API errors: These may occur if the external API is unreachable or returns errors. Check network connectivity and API status.
  • Continue on Fail: If enabled, errors will be returned in the output JSON under an error field instead of stopping execution.

Links and References


If you need details on other operations or resources, please let me know!

Discussion