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:
- Go to "WeChat Terminal Cooperation Platform" - "Query Device Status" and check whether a device with the corresponding
deviceIdhas been registered; - If no related device is found or the query parameters are incorrect, please re-invoke
addDeviceto register the device and enter the correctdeviceIdandmodelName. Please find themodelNamefor payment devices on theMerchantPaymentMerchantPlatform.