Skip to content

Instantly share code, notes, and snippets.

@akhy
Forked from akhoury6/mfatoken.applescript
Created October 16, 2023 01:59
Show Gist options
  • Select an option

  • Save akhy/d1a82ca1d023519593796699583c47e1 to your computer and use it in GitHub Desktop.

Select an option

Save akhy/d1a82ca1d023519593796699583c47e1 to your computer and use it in GitHub Desktop.

Revisions

  1. @akhoury6 akhoury6 created this gist May 19, 2016.
    19 changes: 19 additions & 0 deletions mfatoken.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    -- Settings
    set mfaSecret to "<token>"

    -- Install oath-toolkit if not available
    try
    do shell script "which /usr/local/bin/oathtool"
    on error
    display dialog "This script needs to install oath-toolkit. Please ensure that brew is installed, then hit OK to continue."
    do shell script "brew install oath-toolkit"
    end try

    -- Generate key
    set generated_key to do shell script "/usr/local/bin/oathtool --totp -b " & mfaSecret
    set the clipboard to generated_key

    -- Paste into Application
    tell application "System Events"
    keystroke generated_key
    end tell