Monday, June 6, 2016

Tasker Pro: Copy Two-Factor Authentication Codes without Changing Apps!

Automation is supposed to be about simplifying everyday tasks to give you more precious time doing the things you love. At XDA, we’ve shown you how you can use Tasker to secure your device, improve productivity, or make driving safer, all a part of our series called ‘Tasker Week.’

But the fun doesn’t end there. If you’ve been itching for some seriously awesome Tasker tasks (and are tired of the boring stuff like telling you how to reboot your phone or shake your phone to wake the display), then our new Tasker Pro series is for you.

We will be posting a series of highly advanced Tasker profiles that will show you just how powerful Tasker can be if you are willing to think outside of the box. Although we’ve done most of the hard work for you and you’re certainly free to import my profiles and use them as-is, I highly recommend you give learning how to use Tasker a shot if you want to be able to customize these tasks yourself. Over on our Tasker Tips & Tricks forums or on Reddit’s /r/Tasker subreddit, you can share and work with others on how to implement an idea you might have (as I have done many times).

This is Week 4 of Tasker pro. Last week, we showed you how you can use Tasker to automatically tag all new photos taken with the title of an ongoing calendar event. This week, we will show you how to copy two-factor authentication codes sent via SMS without leaving your app!


Tasker Pro #4: Copy Two-Factor Authentication Codes

With so many password databases being breached these days, many people who want to make their online accounts more secure are opting to enable two-factor authentication within their services. How a service implements sending you two-factor authentication codes differs from service to service (SMS, e-mail, authenticator app, etc.) so you’ll unfortunately have to rely on whatever method the service you’ve signed up for allows. For the many, many services that send 2FA codes via SMS, it can be a little troublesome to have to open your SMS app to copy the code (and in poorly coded apps, the app might even close before you can paste the 2FA code!)

In that case, we can use Tasker to intercept SMS messages and display a short toast or snackbar with the code on top of whatever app you’re currently using! You can press a button to have it copy to your clipboard, and after 15 seconds your clipboard will be automatically cleared.

paypal1


Requirements

The following are OPTIONAL, however, if you want to exactly replicate my set-up (or just import my script) then you’ll need to install these two plug-ins:


Instructions

This script requires some changes to your contact list before we start. In order for this script to detect when SMS messages are sent by certain institutions, you’ll need to name them as a contact beforehand. For instance, if you receive SMS messages from PayPal for 2FA purposes, then you’ll want to name that contact so Tasker will recognize where the message is from. But here’s the important part: you will want to preface each of the contact names with the same word to make things nice and easy for Tasker. In my case, I named each of my contacts “Verification *” where * is PayPal, LinkedIn, etc. This way Tasker can just parse out the “Verification” part of the name to get the actual institution that sent the 2FA SMS.

paypal2

Here’s the overview of the profile you’ll make. It’s actually quite simple, but we’ll break it down in more detail for you. First thing you need to do is create a new Event Profile that triggers when an SMS is received. For the contact name, make it Verification * which means that any contact that has the term “Verification” in it will trigger this profile, so that means any contact you explicitly named as such. Leave the body part blank, as each institution sends a different text body which we can’t match immediately in the profile.

Now, let’s run down the actions you’ll need for this profile:

paypal3

  1. OPTIONAL: Plugins –> AutoNotification –> AutoNotification Query. Set it to query for a notification sent by your SMS app. This is not really needed but it can save you some time by helping us intercept and automatically dismiss the notification sent by your SMS app as we’re already going to be interacting with it.
  2. Variables –> Variable Set. Set %clip to %CLIP. Save the current message in the clipboard in case we choose to copy the 2FA code.
  3. Variables –> Variable Set. Set %text to %SMSRB. Save the text message body in a variable.
  4. Variables –> Variable Set. Set %from to %SMSRN. Set the contact name to a variable.
  5. Variables –> Variable Search Replace. Variable: %text. Search: \d{3,} Click “Multi-Line“, “One Match Only“, and Store Matches in %code. This will search the text message body for any string of numbers 3 characters in length or greater, which should be the 2FA code. It will store all results in a variable, which should only be a single match.
  6. OPTIONAL: Plugins –> AutoNotification –> AutoNotification Cancel. Other Id: %anid. Package: %anpackage. Tag: %antag. This will dismiss the notification from your SMS app.
  7. OPTIONAL: Plugins –> Snackbar Tasker Plugin –> Snackbar with Button. Message: %from: %code1. Button: COPY. Command: copy. Check If and set it to %code1 is Set. This will display a snackbar with your code and give you a button to copy the text, only if a 2FA code is found.
  8. OPTIONAL: System –> Set Clipboard. Text: %code1. Check if and make it %sb_command ~ copy. This will copy the code to your clipboard if you choose as such.
  9. OPTIONAL: Plugins –> Snackbar Tasker Plugin –> Snackbar Without Button. Message: Copied to clipboard, clearing in 15 sec…
  10. OPTIONAL: Task –> Wait. Wait 15 seconds. The time to wait until you clear your clipboard.
  11. OPTIONAL: System –> Set Clipboard. Text: %clip. This will restore your clipboard.
  12. OPTIONAL: Plugins –> Snackbar Tasker Plugin –> Snackbar Without Button. Message: Clipboard restored.

If you would rather not use the Snackbar Tasker Plugin, then you can just copy the message from step 7 and display a toast message by using Alert –> Flash.


And voila! If you are able to follow along this, then congratulations, you’re pretty much a master of Tasker! Confused on a step and just want to import the script and get on with your life? I can’t blame you, this one took myself a lot of thinking to get it down right.

If you want to import this profile, you can download it from Android File Host hereIn order to import the task, you need to first disable Beginner Mode in Tasker by going to the menu –> preferences. Under the UI tab, uncheck ‘Beginner Mode.’ Then back in the main Tasker menu, click on the ‘Tasks’ tab. Then long-press on the ‘Tasks’ tab and press ‘Import.’ Navigate to where you downloaded my .prf.xml file and select it to import it. Once you import it, you’re free to play around with it as you see fit.

Next week for Tasker Pro I will show you how to save workplace embarrassment by making sure you always have an alarm ready in the morning, and to disable any alarms you accidentally set!

Check out all Tasker Pro scripts!!

What would you like to see me make with Tasker? Let us know below and we might feature your idea in a future article!

HostGator Web Hosting

0 comments:

Post a Comment