Zalo icon

Zalo

Send messages and interact with Zalo Official Account API

Overview

The "Generate PKCE Parameters" operation of the Zalo n8n node is designed to facilitate the OAuth 2.0 PKCE (Proof Key for Code Exchange) authorization flow with Zalo's Official Account API. This operation generates a secure code verifier and code challenge, then constructs an authorization URL that you can use to initiate the OAuth process in your browser.

Common scenarios:

  • When you need to connect your Zalo Official Account to n8n securely using OAuth 2.0 with PKCE.
  • When setting up or reauthorizing Zalo API credentials in n8n.
  • For developers or administrators who want to automate the process of obtaining access tokens for Zalo integrations.

Practical example:
You are building a workflow that sends messages via Zalo. Before sending messages, you must authorize your n8n instance with Zalo. You use this operation to generate the necessary PKCE parameters and get the authorization URL, which you open in your browser to complete the authorization.


Properties

Name Type Meaning
App ID String Your Zalo App ID from the Zalo Developer Portal. Used to identify your application during authorization.
Redirect URI String The URI where Zalo will redirect after authorization. Must match one configured in your Zalo app settings.

Output

The node outputs a single item with the following json structure:

{
  "success": true,
  "codeVerifier": "<string>",
  "codeChallenge": "<string>",
  "authorizationUrl": "<string>",
  "instructions": "<string>",
  "note": "<string>"
}
  • success: Indicates if the operation was successful (true or false).
  • codeVerifier: The generated PKCE code verifier (a random string).
  • codeChallenge: The corresponding PKCE code challenge (SHA256 hash, base64-url encoded).
  • authorizationUrl: The full URL to open in your browser to start the Zalo OAuth authorization process.
  • instructions: Step-by-step guidance on how to proceed with the authorization.
  • note: Additional information about credential management in n8n.

If an error occurs and "Continue On Fail" is enabled, the output will be:

{
  "success": false,
  "error": "<error message>"
}

Dependencies

  • Zalo Official Account API: Requires a registered Zalo app and its App ID.
  • n8n Credentials: The ZaloCredentialsManager node should be used to manage the Secret Key and handle token exchange automatically.
  • No external API keys required for this step, but subsequent steps (token exchange, messaging) require the Zalo app's Secret Key.

Troubleshooting

Common issues:

  • Invalid App ID or Redirect URI: If these values do not match your Zalo app configuration, the authorization will fail.
  • Redirect URI mismatch: Ensure the Redirect URI exactly matches one registered in the Zalo Developer Portal.
  • Browser does not open the authorization URL: Copy and paste the provided URL into your browser manually.

Error messages:

  • "Failed to generate PKCE parameters: <error>": Indicates an internal error during parameter generation. Double-check input values.
  • "success": false, "error": "<error message>": Returned in the output if "Continue On Fail" is enabled; check the error message for details.

How to resolve:

  • Verify your App ID and Redirect URI in both n8n and the Zalo Developer Portal.
  • Follow the instructions in the output carefully.
  • If problems persist, consult Zalo's OAuth documentation.

Links and References

Discussion