AcrossFlow Start free

Old mini program: self-developed and WeChat authorization

Once the old mini program is authorized to AcrossFlow, or a self-developed mini program's AppSecret is provided, its relay page requests jump tokens with a wx.login code, with no backend changes. WeChat authorization is coming soon.

MethodURLCalled byAuthentication
POSThttps://open.acrossflow.com/v1/mp/jumpOld mini program's relay pagewx.login code
WeChat authorization coming soon

This endpoint currently serves self-developed channels; see Self-developed mini programs. WeChat authorization channels cannot be created in the Dashboard yet. If the backend can change, you can also use server integration.

This endpoint is for cases where the old mini program's backend cannot be changed. Once the old mini program is authorized to AcrossFlow, or the merchant provides a self-developed mini program's AppSecret in the Dashboard, its relay page requests jump tokens directly with a wx.login code; WeChat vouches for the member's identity and no access token is involved. For response structure and common error codes, see the API overview.

Call sequence

Relay pageAcrossFlowWeChatNew mini program
  1. wx.login
  2. Login code
  3. /v1/mp/jump with the AppID and code
  4. Verify the code
  5. The member's OpenID
  6. Single-use jump token
  7. wx.navigateToMiniProgram with af_token
The old backend is not involved. WeChat authorization channels verify the code as the third-party platform; self-developed channels use the mini program's AppSecret.
  1. The member starts a jump in the old mini program. The relay page calls wx.login to obtain a login code.
  2. The relay page calls /v1/mp/jump with the old mini program's AppID and the code.
  3. AcrossFlow verifies the code with WeChat (as the authorized third-party platform for WeChat authorization channels, or with the mini program's AppSecret for self-developed channels), obtains the member's OpenID, and issues a single-use jump token.
  4. The relay page opens the new mini program with wx.navigateToMiniProgram, passing the token as af_token both in the landing path's query string and in extraData.
  5. The new mini program's backend redeems the token, credits the member, and reports the migration; see Redeem jump tokens and report migrations.

Prerequisites

  • Create the channel in the Dashboard. For WeChat authorization, choose WeChat authorization and authorize the old mini program to AcrossFlow as prompted; for a self-developed channel, see Self-developed mini programs. Then import the member sheet and configure the jump target.
  • On the channel's Integration tab, create a Redeem token for the new mini program's backend. This endpoint itself needs no access token.
  • In the old mini program's admin console, add https://open.acrossflow.com as a request domain. If you also add a web-view page for the jump page built in the Dashboard, add app.acrossflow.com as a business domain too. Both need an ICP filing and acrossflow.com has none: a mini program registered in mainland China cannot add them and cannot use this endpoint, so use server integration instead. Mini programs registered outside mainland China can usually add them, though WeChat notes unfiled links may be unstable.
  • The channel's Integration tab shows its jump page URL. Complete page code is under Example.
  • The old mini program's privacy policy must state that the member's WeChat login credential is shared with AcrossFlow to identify members.

Self-developed mini programs

If the merchant develops the old mini program and can obtain its AppSecret, it does not need to be authorized to AcrossFlow. Create the channel in the Dashboard as Self-developed and enter the old mini program's AppID and AppSecret. Relay page code, domain configuration, and the privacy policy requirement are the same as above. For how to choose an integration and how AcrossFlow uses and stores the AppSecret, see Choose how the old mini program connects.

  • The AppSecret is under Development Management → Development Settings in the WeChat Official Accounts Platform. Before saving, AcrossFlow checks with WeChat that the AppID and AppSecret match, then stores the AppSecret encrypted.
  • The old mini program's API IP whitelist must be turned off. AcrossFlow calls WeChat from egress IPs that are not fixed, so the channel cannot be created while the whitelist is on.
  • AcrossFlow obtains access tokens only through stable_token in normal mode, which does not affect access tokens the old mini program's backend already holds.
  • Resetting the AppSecret in the WeChat Official Accounts Platform invalidates the previous one immediately. This endpoint then returns wechat and the Dashboard shows AppSecret rejected; use Replace AppSecret on the channel.
  • The merchant enables and disables the channel in the Dashboard. A disabled channel stops issuing immediately; jump tokens already issued can still be redeemed.
  • An AppID can be connected to only one WeChat authorization or self-developed channel.

Issue a jump token

POST https://open.acrossflow.com/v1/mp/jump
Content-Type: application/json

{ "appId": "wx…", "code": "<code from wx.login>" }

Request parameters

FieldTypeRequiredDescription
appIdstringYesThe old mini program's AppID: wx followed by 16 hex characters. Read it from wx.getAccountInfoSync().miniProgram.appId
codestringYesThe login code returned by wx.login, up to 128 characters

Response

Same fields as the issue endpoint:

{
  "ok": true,
  "appId": "wx…",
  "path": "pages/index/index",
  "envVersion": "release",
  "token": "…",
  "expiresIn": 600
}

Notes

  • This endpoint is called directly from the mini program and uses no access token; the member's identity comes from the code WeChat verifies.
  • A code is issued by WeChat and can be used once. Call wx.login again for every jump.
  • This endpoint is not idempotent. A retry needs a new code.
  • A member the merchant never imported can still be issued a token; the new mini program then receives member: null on redemption.
  • A WeChat authorization channel stops issuing as soon as the old mini program revokes its authorization to AcrossFlow.

Example

Old mini program pages

Add a relay page that makes the jump to the old mini program, and link to it from an existing entry point such as a home banner or the member centre. To show the jump page built in the AcrossFlow Dashboard inside the old mini program, you can also add a web-view page that opens it and configure a business domain; mini programs registered to an individual or in mainland China cannot use it. Without it, drop pages/acrossflow-page/index and its page below.

Add both paths to the pages list in app.json:

{
  "pages": [
    "pages/acrossflow-page/index",
    "pages/acrossflow-jump/index"
  ]
}

pages/acrossflow-page/index.wxml, using the jump page URL shown on the channel's Integration tab:

<web-view src="https://app.acrossflow.com/p/chn_…"></web-view>

pages/acrossflow-jump/index.js:

const API = "https://open.acrossflow.com/v1/mp/jump";

Page({
  data: { state: "loading", message: "" },
  onShow() {
    this.prepare();
  },
  prepare() {
    this.target = null;
    this.setData({ state: "loading" });
    const appId = wx.getAccountInfoSync().miniProgram.appId;
    wx.login({
      success: ({ code }) => {
        wx.request({
          url: API,
          method: "POST",
          data: { appId, code },
          success: ({ data }) => this.ready(data),
          fail: () => this.setData({ state: "error", message: "Network unavailable" }),
        });
      },
      fail: () => this.setData({ state: "error", message: "Sign-in failed" }),
    });
  },
  ready(data) {
    if (data && data.ok) {
      this.target = data;
      this.setData({ state: "ready" });
    } else {
      this.setData({ state: "error", message: "Unable to continue right now" });
    }
  },
  go() {
    const t = this.target;
    if (!t) return;
    const options = {
      appId: t.appId,
      envVersion: t.envVersion,
      extraData: { af_token: t.token },
    };
    if (t.path) options.path = t.path + (t.path.includes("?") ? "&" : "?") + "af_token=" + t.token;
    wx.navigateToMiniProgram(options);
  },
});

pages/acrossflow-jump/index.wxml:

<view style="padding: 120rpx 48rpx; text-align: center;">
  <button wx:if="{{state === 'ready'}}" type="primary" bindtap="go">Go now</button>
  <block wx:elif="{{state === 'error'}}">
    <view style="margin-bottom: 24rpx; color: #888;">{{message}}</view>
    <button size="mini" bindtap="prepare">Retry</button>
  </block>
  <view wx:else style="color: #888;">Preparing…</view>
</view>

Error codes

Error codes specific to this endpoint. For common error codes, see the API overview.

HTTPerrorDescription
400codecode is missing or longer than 128 characters
400wechatWeChat rejected the code (invalid, expired, or already used), the self-developed channel's AppSecret was reset, or WeChat is temporarily unavailable
402pausedThe merchant's account is over its plan limits and the grace period has ended, so jumps are paused. Jump tokens already issued can still be redeemed
403channelappId is malformed or not connected to AcrossFlow, its authorization was revoked, or the channel is disabled or deleted
409targetThe channel has no jump target configured