Synthetic monitoring supports many authentication methods for your applications.

First-factor authentication methods:

Authentication MethodDescription

Username and password

Supported using Credential Vault

Single sign-on (SSO)

You can store the credentials in the Credential Vault. Then, use the SSO URL and the credentials in the script.

Passkey

Store the passkey in the Credential Vault. Then, use the passkey in the script.

Certificate-based authentication

Use the Credential Vault to store the certificate.

Microsoft AD

Create a service account in Microsoft AD. Then, use the service account in the script.

Multi-factor authentication methods:

  • SMS
  • Email
  • Azure AD
  • Time-based One-time password (TOTP):
    Private Synthetic Agent supports the TOTP method. You can use the pyotp libraries for Web Monitoring and otplib for API Monitoring. The following is an example of how to use these libraries:


    import time
    import pyotp
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.support.ui import WebDriverWait
    
    TOTP_SECRET = '<%totp_secret%>'
    
    # Initialize the TOTP generator
    totp = pyotp.TOTP(TOTP_SECRET)
    
    
    # Generate the current TOTP code and send it to OTP field
    totp_code = totp.now()
    auth_field=wait.until(EC.visibility_of_element_located((By.ID, 'app_totp')))
    auth_field.send_keys(totp_code)
    CODE


    const { totp } = require('otplib')
    
    // Replace these with your actual values
    const apiUrl = 'https://api.github.com/user';
    const personalAccessToken = '<%TOKEN-IN-CREDENTIALS-VAULT%>';
    const totpSecret = '<%base64-secret-stored-in-secrets%>';
    
    // Generate TOTP code
    const totpCode = totp.generate(totpSecret);
    
    async function callGitHubApiWithMfa() {
      try {
        var response = await client.get(apiUrl, {
          headers: {
            'Authorization': `token ${personalAccessToken}`,
            'X-GitHub-OTP': totpCode
          }
        });
    
        console.log('API Response:', response.body);
      } catch (error) {
        console.error('Error calling GitHub API:', error.response ? error.response.data : error.message);
      }
    }
    
    callGitHubApiWithMfa();
    CODE