Get User Identifier (Generic Auth)
Description
A redirect-style endpoint for obtaining user identifiers (openId / userId). The caller builds a signed URL and guides the user's browser to it; after the platform completes third-party OAuth, it redirects back to the caller's callback URL with the user identifier and signature.
Use cases: obtaining a WeChat openId / Alipay userId / Douyin openId through DaxPay for your own business (non-payment scenarios).
Request
GET /unipay/open/auth/get-openid
- Auth: RSA signature (all parameters are signed)
- Response: 302 redirect (not JSON)
Parameters
| Parameter | Type | Required | Max | Description |
|---|---|---|---|---|
| mchNo | string | Yes | 32 | Merchant number |
| appId | string | No | 32 | App number |
| authType | string | Yes | 32 | Auth type (wechat / alipay / douyin) |
| redirectUrl | string | Yes | 500 | Callback URL (redirect target after the identifier is obtained; RESTful style, do not append query params) |
| channelMchNo | string | No | 32 | Channel merchant number (locates the channel app for WeChat/Douyin) |
| reqId | string | Yes | 64 | Request ID (generated by the caller, signed) |
| reqTime | string | Yes | - | Request time (Beijing time, format yyyy-MM-dd HH:mm:ss, signed) |
| nonceStr | string | No | 32 | Random string (signed) |
| sign | string | Yes | 1024 | Merchant signature (signed with the merchant private key; all non-empty params sorted in ASCII order) |
Request Example
GET /unipay/open/auth/get-openid?mchNo=M200000001&appId=APP001&authType=wechat&redirectUrl=https%3A%2F%2Fwww.merchant.com%2Fcallback&reqId=REQ20241201020&reqTime=2024-12-01+12%3A00%3A00&nonceStr=abc123&sign=Base64SignatureResponse Flow
Step 1: 302 redirect to third-party OAuth
After signature verification, the platform returns a 302 redirect to the third-party (WeChat/Alipay/Douyin) OAuth authorization page.
Step 2: OAuth callback
After the user authorizes, the third party calls back /unipay/open/auth/callback?code=xxx&state=authToken; the platform exchanges the code for the user identifier.
Step 3: 302 redirect to the caller's callback URL
The platform appends the user identifier and signature as query parameters and redirects (302) to the caller's redirectUrl:
https://www.merchant.com/callback?return_code=10000&return_msg=success&openid=oUpF8uMuAJO_M2pxb1Q9zNjWeS6o&sign=Base64SignatureCallback Parameters
Parameters carried when redirecting to the caller's redirectUrl:
| Parameter | Type | Description |
|---|---|---|
| return_code | string | Status code: 10000=success, 10001=failure |
| return_msg | string | Status description |
| openid | string | User identifier (WeChat/Douyin scenarios) |
| userid | string | User identifier (Alipay scenarios) |
| sign | string | Platform signature (verify with the platform public key) |
Success Callback Example
https://www.merchant.com/callback?return_code=10000&return_msg=success&openid=oUpF8uMuAJO_M2pxb1Q9zNjWeS6o&sign=953A3CE8C278BB7A8BA277419724C3FDFailure Callback Example
https://www.merchant.com/callback?return_code=10001&return_msg=Failed to obtain openId&sign=...Channel Notes
| authType | Auth method | Config source | Returned identifier |
|---|---|---|---|
| Official Account OAuth (snsapi_base silent) | WeChat app bound to the merchant channel (WxAppFacade) | openid | |
| alipay | auth_base silent authorization | Platform-level Alipay config (PlatformAlipayAuthConfig) | userid |
| douyin | H5 silent_auth | Douyin app bound to the merchant channel (DouyinDirectApp) | openid |
Douyin limitation
Douyin silent_auth only works inside the Douyin App WebView. Make sure the user opens the auth link inside the Douyin App.
Signature Verification
Callback parameters follow the same signature rules as payment endpoints:
- Sort parameter names in ASCII order
- Empty values are excluded from signing
- Verify with the platform public key
See Signature.