Authorize

View Markdown

Last edited on 2026-07-05

It is recommended to use the WMPFAccountApi.login API.

Used to initiate QR code login.

Call Parameters

Attribute Description
needOauthCode Whether WeChat login credentials are required. Defaults to false. If set to true, ensure that the hostAppId has developer qualifications; otherwise, the setting will be invalid.

Return Parameters

Attribute Description
oauthCode WeChat login authorization credential. For details, see documentation

Sample Code

val request = WMPFAuthorizeRequest()
request.baseRequest = WMPFBaseRequestHelper.checked()
// OauthCode is required. Set this variable to true.
// OauthCode requires BuildConfig.HOST_APPID to have developer qualifications.
request.needOauthCode = needOauthCode

val result = WMPFIPCInvoker.invokeAsync<IPCInvokerTask_Authorize,
        WMPFAuthorizeRequest, WMPFAuthorizeResponse>(
    request,
    IPCInvokerTask_Authorize::class.java
) { response ->
    Log.i(response)
    if (isSuccess(response)) {
        it.onSuccess(response)
    } else {
        it.onError(TaskErrorException(createTaskError(response)))
    }
}

if (!result) {
    it.onError(Exception("invoke authorize fail"))
}

FAQ

If an error is returned after calling the API and errMsg contains error code 10006 (the app does not have Mini Program login permissions), please follow these steps:

  1. Go to "WeChat Terminal Cooperation Platform" - "Query Device Status" and check whether a device with the corresponding deviceId has been registered;
  2. If no related device is found or the query parameters are incorrect, please re-invoke addDevice to register the device and enter the correct deviceId and modelName. Please find the modelName for payment devices on the Merchant Payment Merchant Platform.