“Your Google verification code is 431973”
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 can’t have the cake and eat it at the same time… or can you? This is where Tasker Authentication Helper comes in!
Tasker Authentication Helper
I’m going to use the Tasker Authentication Helper to get the code out of the text message, not matter what the text message is, then send it as a clipboard to other devices via Join? Sounds good? I think this should save me a lot of time, especially when used with the 2-step authentication systems. And while I’m at it, let’s make the project as universal as possible, so it would work with all verification messages!
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.
I have to admit, that most often the simple profiles are the one that solves the annoying issues. Tasker Authentication Helper is very simple. It took me a while to fail miserably at regex. I have not been able to find a single regex formula, but the profile works well with 2 filters working together. If you are a PRO in regex, feel free to combine both formulas together and let me know!
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 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 ]
I’m using AutoNotification (*but nothing should stop you from using a build in Tasker’s SMS received condition – further modifications needs to be done to variables) to intercept the message. A simple filter of the %antext (pin|code) 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.
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
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 for this.
code is 431973
PIN 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 shared with other devices with Join app.
Tasker Authentication Helper project works fast and speeds up the 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. I hope you will find this project useful. Share it with your friends and give it a like while you here. If you are feeling particularly charitable you can also support me directly by funding my projects. If you wish to download a project file please use this link.