This probably won't help, but you might get a laugh out of it.
When I saw your post about Perl and SharePoint, I remember stumbling across a blog post that had me laughing. I don't even remember what I was searching for when I came across it. The blog post that I'm referring to can be found here. Here's the part that cracked me up since I did not enjoy maintaining a SharePoint site at $work and I like to use Perl.
Why on earth would these two disparate camps ever meet? Perl is 15 million years old, right, and SharePoint is the bane to system administrators everywhere. The small “SharePerl” audience includes me, and two or three really old techs that still use land line phones.
Anyways, that blog post was dealing with using Perl to access SharePoint. However, I don't think its dealing with 2 factor authentication. Like I said, probably not all that helpful, but thought I'd share anyways.