WeChatAdapter

new WeChatAdapter(options)

Parse Server Configuration

To configure Parse Server for WeChat authentication, use the following structure:

Secure Configuration (Recommended)

{
  "auth": {
    "wechat": {
      "clientId": "your-client-id",
      "clientSecret": "your-client-secret"
    }
  }
}

Insecure Configuration (Not Recommended)

{
  "auth": {
    "wechat": {
      "enableInsecureAuth": true
    }
  }
}

The adapter requires the following authData fields:

  • With enableInsecureAuth (Not Recommended): id, access_token.
  • Without enableInsecureAuth: code.

Auth Payloads

Secure Authentication Payload (Recommended)

{
  "wechat": {
    "code": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Insecure Authentication Payload (Not Recommended)

{
  "wechat": {
    "id": "1234567",
    "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Notes

  • With enableInsecureAuth, the adapter directly validates the id and access_token sent by the client.
  • Without enableInsecureAuth, the adapter uses the code provided by the client to exchange for an access token via WeChat's OAuth API.
  • The enableInsecureAuth flag is deprecated and may be removed in future versions. Use secure authentication with the code field instead.
Parameters:
NameTypeDescription
optionsObject

The adapter options object.

Properties
NameTypeAttributesDefaultDescription
enableInsecureAuthboolean<optional>
false

[DEPRECATED] Enable insecure authentication (not recommended).

clientIdstring

Your WeChat App ID.

clientSecretstring

Your WeChat App Secret.

Example

Auth Data Example

// Example authData provided by the client:
const authData = {
  wechat: {
    code: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
};