tencent cloud

Feedback

‌Integration Process

Last updated: 2024-01-25 10:37:31
    This document introduces the overall integration process of eKYC liveness detection and face comparison (mobile HTML5).
    

    Preparations

    Sign up for a Tencent Cloud account. For more information, see Signing Up.
    Complete enterprise identity verification. For more information, see Enterprise Identity Verification Guide.
    Log in to the eKYC console.
    

    Overall Architecture

    The following figure shows the architecture of eKYC liveness detection and face comparison (mobile HTML5).
    
    
    

    

    Overall Interaction Process

    The following figure shows the overall interaction logic between a user and Tencent Cloud eKYC. The roles involved are described as follows:
    User: Mobile HTML5 client.
    Merchant WebPage: Merchant's frontend page.
    Merchant Server: Merchant's backend service.
    eKYC WebPage: eKYC frontend page.
    eKYC Server: eKYC backend service.
    Step1.png#924px #715px
    
    The recommended detailed interaction process is as follows:

    Phase 1

    1. A user starts a business, which triggers the verification process.
    2. The Merchant WebPage sends a request to the Merchant Server, informing it to initiate a verification process.
    3. The Merchant Server calls the ApplyWebVerificationBizTokenIntl API, passing in relevant parameters. For more information, see the description of step 1 in "Server-Side Integration".
    4. After receiving the request, the eKYC Server returns the BizToken and VerificationURL for the verification process to the Merchant Server.
    5. The Merchant Server stores the obtained BizToken and sends the VerificationURL to the Merchant WebPage.

    Phase 2

    6. The Merchant WebPage redirects to the VerificationURL to open the eKYC WebPage. For more information, see the description of step 1 in "Client-Side Integration".
    7. The user completes the verification process on the eKYC WebPage.
    8. After the verification is completed, the eKYC Server sends the verification result to the eKYC WebPage, and the Merchant WebPage displays the result page.
    9. After the user taps "Next", the eKYC WebPage redirects back to the RedirectURL, with the token parameter added.
    10. The Merchant WebPage obtains the token parameter for the current verification process from the URL. For more information, see the description of step 2 in "Client-Side Integration".

    Phase 3

    11. The Merchant WebPage sends a request to the Merchant Server, informing it to obtain the verification result.
    12. The Merchant Server calls the GetWebVerificationResultIntl API, passing in relevant parameters. For more information, see the description of step 2 in "Server-Side Integration".
    13. After receiving the request, the eKYC Server returns the detailed information of the verification process to the Merchant Server.
    14. The Merchant Server sends the result back to the Merchant WebPage, which then proceeds with the subsequent business process based on the result.

     

    Server-Side Integration

    1. Generate the verification URL (corresponding to Phase 1)

    Call ApplyWebVerificationBizTokenIntl to obtain the values of BizToken and VerificationURL. This corresponds to step 3 in the interaction process.
    ‌CompareImageBase64: The Base64-encoded string (max 8 MB in size) of the photo to be compared.
    ‌RedirectURL: Set this parameter to the web callback URL to redirect to after the verification is completed. ‌RedirectURL should include the protocol, hostname, and path. An example value is https://www.tencentcloud.com/products/faceid. After the verification process is completed, the BizToken of this process will be added to the callback URL in the format of https://www.tencentcloud.com/products/faceid?token={BizToken} before redirect.
    Extra: The passthrough parameter of the business, max 1,000 characters, which will be returned in GetWebVerificationResultIntl.
    Config: Custom configuration for the verification page. This is optional.
    
    The data structure of Config is as follows:
    AutoSkip: When verification is successful, whether to skip the result display page and automatically redirect to RedirectURL. The default value is false.

    Sample API call:

    package main
    
    import (
    "fmt"
    "os"
    
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common"
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile"
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/regions"
    faceid "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/faceid/v20180301"
    "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
    )
    
    func ApplyWebVerificationBizTokenIntl(imageBase64 string) {
    // Set TencentCloud API access key
    credential := common.NewCredential(
    os.Getenv("TENCENTCLOUD_SECRET_ID"),
    os.Getenv("TENCENTCLOUD_SECRET_KEY"),
    )
    cpf := profile.NewClientProfile()
    client, _ := faceid.NewClient(credential, regions.Singapore, cpf)
    request := faceid.NewApplyWebVerificationBizTokenIntlRequest()
    request.RedirectURL = common.StringPtr("https://www.tencentcloud.com/products/faceid")
    // Pass in CompareImageBase64 and Extra
    request.CompareImageBase64 = common.StringPtr(imageBase64)
    request.Extra = common.StringPtr("ExtraString")
    response, err := client.ApplyWebVerificationBizTokenIntl(request)
    if _, ok := err.(*errors.TencentCloudSDKError); ok {
    fmt.Printf("An API error has returned: %s", err)
    return
    }
    if err != nil {
    panic(err)
    }
    // Obtain BizToken and VerificationURL
    bizToken := *response.Response.BizToken
    verificationURL := *response.Response.VerificationURL
    fmt.Printf("BizToken: %s, VerificationURL: %s", bizToken, verificationURL)
    }

    2. Check the verification result (corresponding to Phase 3)

    After the verification process is completed, the merchant frontend requests the merchant server to obtain the verification result. The merchant server then calls the GetWebVerificationResultIntl API to obtain the final result and returns it to the frontend page. This corresponds to step 12 in the interaction process.
    The final verification result is subject to the information returned by this API. When ErrorCode in the response is 0, it indicates that the verification is successful. In other cases, verification failed. For other error codes, see Liveness Detection and Face Comparison (Mobile HTML5) Error Codes.‌
    BizToken: The BizToken generated by the ApplyWebVerificationBizTokenIntl API, which is a unique identifier for the current verification process.

    Sample API call:

    package main
    
    import (
    "fmt"
    "os"
    
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common"
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile"
    "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/regions"
    faceid "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/faceid/v20180301"
    "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
    )
    
    func GetWebVerificationResult(bizToken string) {
    // Set TencentCloud API access key
    credential := common.NewCredential(
    os.Getenv("TENCENTCLOUD_SECRET_ID"),
    os.Getenv("TENCENTCLOUD_SECRET_KEY"),
    )
    cpf := profile.NewClientProfile()
    client, _ := faceid.NewClient(credential, regions.Singapore, cpf)
    request := faceid.NewGetWebVerificationResultIntlRequest()
    // Pass in BizToken
    request.BizToken = common.StringPtr(bizToken)
    response, err := client.GetWebVerificationResultIntl(request)
    if _, ok := err.(*errors.TencentCloudSDKError); ok {
    fmt.Printf("An API error has returned: %s", err)
    return
    }
    if err != nil {
    panic(err)
    }
    if response.Response.ErrorCode == nil {
    fmt.Print("the verification is uncompleted.")
    return
    }
    errorCode := *response.Response.ErrorCode
    errorMsg := *response.Response.ErrorMsg
    if errorCode == 0 {
    // Verification succeeded
    fmt.Print("Success")
    }else{
    // Verification failed
    fmt.Printf("Fail: %s\\n", errorMsg)
    }
    }

    

    Client-Side Integration

    1. Use VerificationURL to initiate verification (corresponding to Phase 2)

    The client frontend page redirects to the VerificationURL received from the server to initiate the verification process. The user completes the liveness detection and face comparison process as prompted. This corresponds to step 6 in the interaction process.

    Sample code:

    // Obtain VerificationURL from the server
    const VerificationURL = 'https://sg.faceid.qq.com/reflect/?token=*****';
    // Redirect the frontend page
    window.location.href = VerificationURL;

    2. Obtain BizToken from the callback address and request the verification result from the backend (corresponding to Phase 2)

    After the verification is completed, the page is redirected to RedirectURL. The BizToken parameter for the current process is added to the RedirectURL. By parsing the RedirectURL, you can obtain the BizToken parameter, which is used to obtain the verification result. This corresponds to step 12 in the interaction process.

    Sample code:

    // Obtain RedirectURL
    const RedirectURL = "https://*?token={BizToken}";
    
    // Parse RedirectURL to obtain the BizToken parameter, which is used to obtain the verification result
    const bizToken = getURLParameter(RedirectURL, "token");
    if (bizToken) {
    // Use bizToken to obtain the verification result
    }
    
    /**
    / * Get URL parameters
    /* @params url The URL to be queried
    /* @params variable The parameter to be queried
    */
    function getURLParameter(url, variable) {
    const query = url.split('?')[1] || '';
    const vars = query.split('&');
    for (let i = 0; i < vars.length; i++) {
    const pair = vars[i].split('=');
    if (pair[0] == variable) {
    return pair[1];
    }
    }
    return (false);
    }
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support