Skip to content

Get User Identifier (Generic Auth)

Updated: 9/16/26, 9:53:37 PM

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

ParameterTypeRequiredMaxDescription
mchNostringYes32Merchant number
appIdstringNo32App number
authTypestringYes32Auth type (wechat / alipay / douyin)
redirectUrlstringYes500Callback URL (redirect target after the identifier is obtained; RESTful style, do not append query params)
channelMchNostringNo32Channel merchant number (locates the channel app for WeChat/Douyin)
reqIdstringYes64Request ID (generated by the caller, signed)
reqTimestringYes-Request time (Beijing time, format yyyy-MM-dd HH:mm:ss, signed)
nonceStrstringNo32Random string (signed)
signstringYes1024Merchant 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=Base64Signature

Response 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=Base64Signature

Callback Parameters

Parameters carried when redirecting to the caller's redirectUrl:

ParameterTypeDescription
return_codestringStatus code: 10000=success, 10001=failure
return_msgstringStatus description
openidstringUser identifier (WeChat/Douyin scenarios)
useridstringUser identifier (Alipay scenarios)
signstringPlatform 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=953A3CE8C278BB7A8BA277419724C3FD

Failure Callback Example

https://www.merchant.com/callback?return_code=10001&return_msg=Failed to obtain openId&sign=...

Channel Notes

authTypeAuth methodConfig sourceReturned identifier
wechatOfficial Account OAuth (snsapi_base silent)WeChat app bound to the merchant channel (WxAppFacade)openid
alipayauth_base silent authorizationPlatform-level Alipay config (PlatformAlipayAuthConfig)userid
douyinH5 silent_authDouyin 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:

  1. Sort parameter names in ASCII order
  2. Empty values are excluded from signing
  3. Verify with the platform public key

See Signature.

Official Website · Released under the GNU LGPL v3.0