---
title: "Generating a Time-based One Time Password (TOTP) in Google Apps Script"
author: "Martin Hawksey"
date: 2023-04-12T19:22:02+00:00
canonical_url: https://pulse.appsscript.info/p/2023/04/generating-a-time-based-one-time-password-totp-in-google-apps-script/
markdown_url: https://pulse.appsscript.info/p/2023/04/generating-a-time-based-one-time-password-totp-in-google-apps-script.md
categories:
  - "Intermediate"
  - "Solutions"
tags:
  - "tanaikech.github.io"
featured_image: https://pulse.appsscript.info/files/2023/04/DALL·E-2023-04-12-20.21.09-abstract-visualization-of-time-based-one-time-passwords.png
description: "For UK readers, no not Top of the Pops (TOTP), but Time-based One Time Passwords (TOTP). In the context of Google Workspace it's more than likely that you can rely on the built-in Google Identity and account security features rather than rolling your own form of two-factor authentication (2FA). Should you be in such a situation when you need to authenticate outside of Google then this example integration of the OTPAuth library in Google Apps Script might be of interest. Rather than just updating a Google Sheet you could combine with MailApp/GmailApp to email the passcode for the user to use. See the source post for implementation information and caveats. "
---

# Generating a Time-based One Time Password (TOTP) in Google Apps Script

![Generating a Time-based One Time Password (TOTP) in Google Apps Script](https://pulse.appsscript.info/files/2023/04/DALL·E-2023-04-12-20.21.09-abstract-visualization-of-time-based-one-time-passwords.png)

> [https://tanaikech.github.io/2023/04/04/putting-totp-into-google-spreadsheet-using-google-apps-script/](https://tanaikech.github.io/2023/04/04/putting-totp-into-google-spreadsheet-using-google-apps-script/)
> In this post, I would like to introduce a sample script for putting Time-based One-time Password (TOTP) value into Google Spreadsheet using Google Apps Script.

For UK readers, no not Top of the Pops (TOTP), but Time-based One Time Passwords (TOTP). In the context of Google Workspace it’s more than likely that you can rely on the built-in Google Identity and account security features rather than rolling your own form of two-factor authentication (2FA). Should you be in such a situation when you need to authenticate outside of Google then this example integration of the OTPAuth library in Google Apps Script might be of interest. Rather than just updating a Google Sheet you could combine with `MailApp`/`GmailApp` to email the passcode for the user to use. See the source post for implementation information and caveats.

Source: [Putting TOTP into Google Spreadsheet using Google Apps Script**](https://tanaikech.github.io/2023/04/04/putting-totp-into-google-spreadsheet-using-google-apps-script/)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2023/04/generating-a-time-based-one-time-password-totp-in-google-apps-script/](https://pulse.appsscript.info/p/2023/04/generating-a-time-based-one-time-password-totp-in-google-apps-script/)*
