pyauth / pyotp

Python One-Time Password Library
https://pyauth.github.io/pyotp/
Other
2.97k stars 323 forks source link

Issue on QR code from Microsoft. #120

Closed thetbenjo closed 3 years ago

thetbenjo commented 3 years ago

Hi

Just want to ask as we're experiencing issue on ready QR code MFA from Microsoft. As we have our own authenticator app, after reading the QR, the URL is generated like this:

otpauth://totp/CompanyName%3Ait377%40ubiinc.onmicrosoft.com?secret=****ddrtkfb2k&issuer=Microsoft

And we're getting this issue: image

But testing the google QR code, on your documentation, it works from.

otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP

Let me know whats wrong on the generated URL from the QR code from microsoft.

Thanks,

Benjo

kislyuk commented 3 years ago

Thanks for your interest in PyOTP. As alluded in the error message you highlighted, the code generated by Microsoft does not comply with the otpauth URI specification (https://github.com/google/google-authenticator/wiki/Key-Uri-Format), which states:

STRONGLY RECOMMENDED: The issuer parameter is a string value indicating the provider or service this account is associated with, URL-encoded according to RFC 3986. If the issuer parameter is absent, issuer information may be taken from the issuer prefix of the label. If both issuer parameter and issuer label prefix are present, they should be equal.

If you must accommodate this nonstandard behavior in your application, the best solution is to make a custom copy of the pyotp.parse_uri() function and let it bypass this error.