Skip to content

Generate Auth URL

Updated: 7/26/26, 9:23:52 PM

Description

Used to obtain the OAuth authorization URL for fetching user openId / userId in scenarios like WeChat JSAPI, Alipay Mini Program, UnionPay QuickPass, etc.

Flow:

  1. Merchant backend calls this endpoint to get authUrl (with session token) and queryCode.
  2. Merchant frontend redirects the user's browser to authUrl for the channel to complete OAuth.
  3. After authorization, the channel calls back the platform, which associates the session via queryCode.
  4. Merchant obtains openId via Auth Code or polls with queryCode.

This is "fetch openId", not "login"

This endpoint obtains a channel user identifier (openId/userId) before payment. It does NOT involve merchant-system login state.

Request

POST /unipay/assist/channel/auth/generate-auth-url

  • Auth: RSA signature (@PaymentVerify)
  • Response: DaxResult<AuthUrlResult>

Parameters

Common params same as Pay - Common Parameters. Business parameters:

ParameterTypeRequiredMaxDescription
authTypestringNo32Auth type (wechat/alipay/union_pay/douyin; defaults to wechat)
productstringNo32Payment product code (determines auth strategy; looked up from channelMchNo if missing)
channelAppIdstringNo128Channel App ID to use (overrides auto-resolve; must be pre-configured)
returnPathstringNo200Source redirect path (where frontend lands after auth; saved with session)
capabilitystringNo32Payment capability code (resolves specific app: Official Account / Mini Program)

Example

json
{
  "mchNo": "M200000001",
  "appId": "APP001",
  "reqId": "REQ20241201020",
  "reqTime": "2024-12-01 12:00:00",
  "sign": "Base64Signature",
  "authType": "wechat",
  "returnPath": "/pay/result"
}

Response

DaxResult<AuthUrlResult>, data fields:

FieldTypeDescription
authUrlstringAuthorization URL (frontend redirects here)
queryCodestringQuery identifier (used by Auth Code to restore context)

Example

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "authUrl": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=...&state=...",
    "queryCode": "QC20241201020"
  },
  "sign": "Base64Signature",
  "resTime": "2024-12-01T04:00:00Z",
  "reqId": "REQ20241201020"
}

Released under the GNU LGPL v3.0