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.
| Method | URL | Called by | Authentication |
|---|---|---|---|
POST | https://open.acrossflow.com/v1/mp/jump | Old mini program's relay page | wx.login code |
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
wx.login- Login code
/v1/mp/jumpwith the AppID and code- Verify the code
- The member's OpenID
- Single-use jump token
wx.navigateToMiniProgramwithaf_token
- The member starts a jump in the old mini program. The relay page calls
wx.loginto obtain a logincode. - The relay page calls
/v1/mp/jumpwith the old mini program's AppID and thecode. - AcrossFlow verifies the
codewith 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. - The relay page opens the new mini program with
wx.navigateToMiniProgram, passing the token asaf_tokenboth in the landing path's query string and inextraData. - 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.comas a request domain. If you also add a web-view page for the jump page built in the Dashboard, addapp.acrossflow.comas a business domain too. Both need an ICP filing andacrossflow.comhas 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_tokenin 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
wechatand 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
| Field | Type | Required | Description |
|---|---|---|---|
appId | string | Yes | The old mini program's AppID: wx followed by 16 hex characters. Read it from wx.getAccountInfoSync().miniProgram.appId |
code | string | Yes | The 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
codeWeChat verifies. - A
codeis issued by WeChat and can be used once. Callwx.loginagain 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: nullon 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.
| HTTP | error | Description |
|---|---|---|
| 400 | code | code is missing or longer than 128 characters |
| 400 | wechat | WeChat rejected the code (invalid, expired, or already used), the self-developed channel's AppSecret was reset, or WeChat is temporarily unavailable |
| 402 | paused | The 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 |
| 403 | channel | appId is malformed or not connected to AcrossFlow, its authorization was revoked, or the channel is disabled or deleted |
| 409 | target | The channel has no jump target configured |