Generate Auth URL
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:
- Merchant backend calls this endpoint to get
authUrl(with session token) andqueryCode. - Merchant frontend redirects the user's browser to
authUrlfor the channel to complete OAuth. - After authorization, the channel calls back the platform, which associates the session via
queryCode. - 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:
| Parameter | Type | Required | Max | Description |
|---|---|---|---|---|
| authType | string | No | 32 | Auth type (wechat/alipay/union_pay/douyin; defaults to wechat) |
| product | string | No | 32 | Payment product code (determines auth strategy; looked up from channelMchNo if missing) |
| channelAppId | string | No | 128 | Channel App ID to use (overrides auto-resolve; must be pre-configured) |
| returnPath | string | No | 200 | Source redirect path (where frontend lands after auth; saved with session) |
| capability | string | No | 32 | Payment 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:
| Field | Type | Description |
|---|---|---|
| authUrl | string | Authorization URL (frontend redirects here) |
| queryCode | string | Query 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"
}