Introducing TypingDNA Human Likeness – A Novel Bot Detection Approach for the AI Age 

TypingDNA Verify 2FA Integration Guide

TypingDNA Verify 2FA can be integrated in two ways: OIDC for supported Identity and Access Management (IAM) platforms, or the original Standard API integration for standalone and custom authentication flows.

OIDC integration (for IAM platforms)

If you are using Okta, Ping Identity, or Microsoft Entra ID, start with the OIDC integration. Verify 2FA is added to your existing IAM as a 2FA/MFA authentication method, so users can authenticate by typing 4 words instead of relying on a personal phone or separate authentication device.

OIDC works with the IAM's existing authentication policies and fallback methods. It does not require you to build the Verify 2FA flow directly into your application.

Okta

Add TypingDNA Verify 2FA to Okta as an OIDC Identity Provider and authenticator, then include it in your Okta authentication policies.

Step-by-step: Integrate Verify 2FA with Okta

Ping Identity

Add TypingDNA Verify 2FA to PingOne or PingFederate authentication flows. PingOne DaVinci can be used to include Verify 2FA in MFA, password reset, risk authentication, and other flows.

Step-by-step: Integrate Verify 2FA with Ping Identity

Microsoft Entra ID

Add TypingDNA Verify 2FA to Microsoft Entra ID as an External Authentication Method (EAM).

Step-by-step: Integrate Verify 2FA with Microsoft Entra ID

For more information about OIDC settings and supported flows, see the Verify 2FA OIDC documentation.

Standard integration

The Standard integration is the original standalone Verify 2FA integration. Use it when you want to add Verify 2FA directly to your own web application without relying on an IAM platform.

The Standard integration uses a TypingDNA backend client together with a frontend JavaScript client and a button or iframe. It can use SMS or email OTP as a Root of Trust (RoT) for enrollment and fallback, or it can be configured without a separate RoT.

PHP Standard integration tutorial

The tutorial below shows how to integrate the Standard version of TypingDNA Verify 2FA into a web application using PHP as the back end. The same steps are also explained in the video.

Prerequisites for the Standard PHP integration

To create a working example of the Standard Verify 2FA integration, the following actions need to be taken.

1. Create an account on typingdna.com. The Verify 2FA dashboard will provide you with the clientId, secret and applicationId.

verify

2. Create a localhost environment that will run php applications. For this tutorial we will use XAMPP that can be downloaded from https://www.apachefriends.org/index.html

verify

3. Setup ngrok. Ngrok creates a public url that will be linked to your localhost environment. For security purposes, TypingDNA Verify 2FA will only run on a public url. Ngrok can be downloaded from the following link: https://ngrok.com/

Configuration

The first step is to create a simple php demo application that will run on ngrok.

We will first create a file called index.php that we will place in the htdocs location of xampp. This folder is usually located here: C:\xampp\htdocs

The index.php file will look like this:

Then we will navigate to the ngrok location folder and we will start up the public url with the following command:

ngrok.exe http 80

This will create a public url that will look something like this:

verify

Once the ngrok link has been created, we will setup this link in our Integration section in the Verify 2FA Dashboard.

verify

Make sure you enter just the domain name and you do not include https or http in the name.

✓ Correct: ee503c799d3f.ngrok.io

✗ Incorrect: https://ee503c799d3f.ngrok.io

We will start up our XAMPP Apache server.

verify

By accessing our ngrok link, in this case https://ee503c799d3f.ngrok.io we will see the following page:

verify

Make sure to always use https otherwise TypingDNA Verify 2FA will not work.

Standard API integration

We will need to download the TypingDNA Verify 2FA PHP client (TypingDNAVerifyClient.php) from the TypingDNA GitHub location that is located here: https://github.com/TypingDNA/TypingDNA-Verify-Client/tree/main/php

We will include this at the start of our index.php file.

Next we will initialize TypingDNA Verify 2FA where we will pass as parameters the clientId, secret and applicationId.

$typingDNAVerifyClient = new TypingDNAVerifyClient($client_id, $application_id, $secret);

You will need to initialize the variable with the actual values from the Verify 2FA Dashboard.

Once the variable is initialized we will generate the data attributes required to start TypingDNA Verify 2FA.

$typingDNADataAttributes = $typingDNAVerifyClient->getDataAttributes([
            'phoneNumber' => "0012025551234",
            'language' => "en",
            'mode' => "standard"
        ]);

For this demo we are going to use a phone number as the root of trust.

Our PHP code will look like this:

<?php
    include('TypingDNAVerifyClient.php');

    $typingDNAVerifyClient = new TypingDNAVerifyClient($client_id, $application_id, $secret);

    $typingDNADataAttributes = $typingDNAVerifyClient->getDataAttributes([
        'phoneNumber' => "0012025551234",
        'language' => "en",
        'mode' => "standard"
    ]);
?>

In order to generate the TypingDNA Verify 2FA window we will need to add the following javascript to our code:

Next we will add the button that will start the TypingDNA Verify 2FA window.

The javascript "callbackFn" will be called once the TypingDNA Verify 2FA process is completed.

<script>
    function callbackFn(payload)
    {
        window.location.href = "verify_otp.php?otp=".concat(payload['otp']);
    }
</script>

TypingDNA Verify 2FA will return a payload that will contain the one time password that is generated. For simplicity, in this demo we will navigate to another page and we will pass the one time password as a parameter in the link.

The final version of the index.php will look like this:

Next we will look at the verify_otp.php file. First we will initialize our variable just like we did in index.php.

<?php
    include('TypingDNAVerifyClient.php');
    $typingDNAVerifyClient = new TypingDNAVerifyClient($client_id, $application_id, $secret);
?>

In order to validate that the one time password is correct we will use the validateOTP function that will make an API call to the TypingDNA server if the one time password is correct.

$response = $typingDNAVerifyClient->validateOTP([
    'phoneNumber' => "0012025551234",
], $_GET['otp']);

Next we will print on the screen the response.

print_r($response);

The final version of the verify_otp.php will look like this:

<?php
    include('credentials.php');
    include('TypingDNAVerifyClient.php');
    $typingDNAVerifyClient = new TypingDNAVerifyClient($client_id, $application_id, $secret);

    $response = $typingDNAVerifyClient->validateOTP([
        'phoneNumber' => "0012025551234",
    ], $_GET['otp']);

    print_r($response);
?>
        

Now we can go ahead and test our solution.

Testing

Our initial page will look like this:

verify

We select the Verify 2FA with TypingDNA button and our TypingDNA Verify 2FA window will appear.

verify

After we complete the instruction from the TypingDNA Verify 2FA button we will be redirected to the verify_otp.php page where the result will be displayed.

verify

The success value indicates if it was a valid authentication 1 or if it was invalid 0.


For the production environment, in order to be able to send SMS OTPs you will need to integrate with Twilio in the Verify 2FA dashboard. First log in to your Twilio account and then click on the following button from the dashboard:

verify

For more support, contact us at support@typingdna.com.