Speed up 2 Factor Authentication on Android with Tasker

Speed up 2 Factor Authentication on Android with Tasker

We all know that security online is very important, so many of us have begun using various 2 Factor Authentication methods.

“Your Google verification code is 431973”

But every time I receive this message when I want to log in, I think: oh, come-on! I want to be secure, but how many times do I have to tell you: ‘It’s me Google!’ With security, you usually can’t have the cake and eat it too… or can you? This is where Tasker Authentication Helper comes in! While I’m aware of Google’s sign in from phone feature, this project goes beyond that and should work with any type of SMS-based 2 factor authentication. What we’ll be doing is retrieving the token from a text message and sending it to other devices using Join.


Developer: joaomgcd
Price: $3.49

Join by joaoapps
Join by joaoapps
Developer: joaomgcd
Price: Free

Tasker 2 Factor Authentication Helper

I have to admit, that most often the simplest profiles are the one that solve the most annoying issues. Tasker Authentication Helper is very simple, though it took me a while to fail miserably at regular expressions (regex). I have not been able to find a single regex formula to do this all in one step, but the profile works well with 2 regex filters working together. If you are a pro at regex, feel free to combine both formulas together and let me know!

If you are REALLY concerned about what devices you are sharing this clipboard with, you can limit the devices receiving the code to an active PC in Tasker.

Vanilla Tasker Trigger

While personally, I prefer using the paid AutoNotification Tasker plugin to intercept SMS notifications, you can do this whole setup using just Tasker only – without any paid plugins. The vanilla set up checks each message received, (Received Text message event) trying to parse its content. The text message is stored in the system variable %SMSRB.

Authentication Helper Profile - Vanilla Tasker

Profile: Pin Code Vanilla  Event: Received Text [ Type:Any Sender:* Content:* ]Enter: Grab A Code Txt 

AutoNotification Trigger

Developer: joaomgcd
Price: Free

Unlike the vanilla Tasker trigger, using the AutoNotification intercept we can run the task only if the text message contains the words “pin” or “code”. This way the Tasker profile won’t run on every received text message. I’m using the AutoNotification Intercept trigger to intercept the message. A simple filter of the Notification Text: %antext (pin|code)  set in the context, will assure that I don’t start assigning any values without a reason. Let’s not run the task if we don’t have to.


Authentication Helper Profile

Profile: Pin Code Txt  Event: AutoNotification Intercept [ Configuration:Event Behaviour: true Notification Type: Only Created Notifications Notification App: Signal Notification Text: pin|code (regex) (case ins) Package Name: org.thoughtcrime.securesms ]Enter: Grab A Code 

Getting the 2 Factor Authentication Code

To fish out the code from a text message, we are going to use 2 regex filters. This should prevent incorrect values from being assigned:

  • A text with a number, but without pin or code word.
  • A text with a number that is not a pin or code.
  • A text with multiple numbers. Capture the first match after code/pin.
  • A text with multiple numbers where the code/pin word is placed after the code.

If you are using the Vanilla Tasker trigger please replace the %antext with %SMSRB.

Grab a Code TASK

Grab A Code  A1: Variable Search Replace [ Variable:%antext Search:(code|pin).*?\d+  Ignore Case:On Multi-Line:On One Match Only:On  Store Matches In:%code Replace Matches:Off Replace With: ]  A2: Variable Search Replace [ Variable:%antext Search:^(.*?)\d+  Ignore Case:On Multi-Line:On One Match Only:On  Store Matches In:%code Replace Matches:Off Replace With: ] If [ %code1 !Set ] A3: Variable Search Replace [ Variable:%code1 Search:\d+  Ignore Case:On Multi-Line:On One Match Only:On  Store Matches In:%auth Replace Matches:Off Replace With: ]  A4: Set Clipboard [ Text:%auth1 Add:Off ] 

Please test the message, to make sure that your messages are being filtered accordingly.

Tasker Authentication Helper – regex

To capture the actual code, I’m going to use Regex. I have several different variations stored on my phone and I’m going to use it as an example. I tried to cover the biggest number of scenarios possible, but if your verification text falls outside of the scope of my regex filters – you will have to modify it to your needs.

Let’s start with capturing the numbers after the words pin/code (case insensitive). I’m using www.regex101.com to help with this.


The result is good, but I failed with the last example. Our matches are:

code is 431973code:895941PIN is 4044

Using search/replace action I will store the matches in an array %code. Our match will be placed in the 1st element: %code1. The %code1 won’t be set if the verification text follows the last example. If that’s the case I can set another Regex filter:


Instead of building a very complicated Regex filter (and mostly because it’s a task way above my understanding of Regex), I will just filter the results again. In both circumstances, the second filter will be the same:


The result of the second filter is stored in the %auth array as the first element %auth1. This variable is used to set a clipboard and is shared with other devices via the Join app.


Tasker Authentication Helper project works fast and helps speeds up login times. I think I’m getting too old to remember the short numbers, or simply too old to go and find my mobile each time I want to log in anywhere without compromising my security. The project file below contains both setups (vanilla and AutoNotification). Please pick one and disable the other profile.

Download the Tasker 2 Factor Authentication Helper Project

Download the above ZIP file and extract the contents onto the internal storage of your Android device. Open up Tasker and disable “Beginner Mode” in Preferences. Then, go back to Tasker’s main page and long-press on the home icon in the bottom left corner. You will see an option to “import” a project. Tap that option then find the .prj.xml file you extracted earlier. Once imported, you will see a new tab at the bottom alongside the default home icon in Tasker. This contains the profiles and tasks of this helper project.

Follow the XDA-Developers Tutorials feed for more posts such as this. Also, check out our Tasker Tips & Tricks forum for the latest creations among the automation enthusiasts in our community.

About author

Mat Zolnierczyk
Mat Zolnierczyk

I am passionate about technology, cycling, and art. This would explain why my bike has more computing power than your average office. I own notenoughtech.com and I write for xda-developers.com and pocketables.com Feel free to follow me!

We are reader supported. External links may earn us a commission.