Back to Browse

Automate TOTP 2-Factor Authentication (2FA) with Playwright

31.1K views
Nov 21, 2022
10:17

A short tutorial to help you understand what goes into automating a TOTP-based 2FA flow using Playwright and the OTPAuth library. Goal: Automate a 2FA login using Playwright and OTPAuth. Note: There are multiple libraries out there for TOTP generation. Pick the one you like. Timestamps: 00:00 Introduction 00:33 TOTP for 2FA 01:22 Approaching 2FA automation 02:23 Extracting the TOTP secret 03:48 Recording the script 05:32 Generating the TOTP token 08:19 2FA automation challenges 10:11 Resources Environment: - MacBook Pro (13-inch, M1, 2020) - macOS Monterey (12.2.1) - Node v14.15.4 - Playwright 1.24.2 Resources: - QR decoder: https://zxing.org/w/decode.jspx - OTPAuth library: https://hectorm.github.io/otpauth - The excellent official Playwright docs: https://playwright.dev - IETF RFC6238: https://www.rfc-editor.org/rfc/rfc6238.html - https://ragog.link for more articles and notes Contact: - @rag0g on Twitter - linkedin.com/in/ragog -@Giovanni Rago on the official Playwright Slack channel Disclaimer These videos are meant to teach interested people, professionals and amateurs, how to use browser automation tools such as Playwright to write scripts for testing, synthetic monitoring, scraping and similar use cases. They center around popular websites to demonstrate real world scenarios for automation. Their aim is never to disrupt a website’s availability or violate its terms of service. Before you attempt automation on a publicly available website, make sure you read the terms and conditions around automation (and specifically scraping) and abide by them.

Download

0 formats

No download links available.

Automate TOTP 2-Factor Authentication (2FA) with Playwright | NatokHD