diff --git a/PHPGangsta/GoogleAuthenticator.php b/PHPGangsta/GoogleAuthenticator.php index bf7d116..19c011f 100644 --- a/PHPGangsta/GoogleAuthenticator.php +++ b/PHPGangsta/GoogleAuthenticator.php @@ -103,12 +103,16 @@ public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = arra $width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 200; $height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 200; $level = !empty($params['level']) && array_search($params['level'], array('L', 'M', 'Q', 'H')) !== false ? $params['level'] : 'M'; - - $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.''); + + $urlencoded = urlencode('otpauth://totp/'); + //for microsoft authenticator to get the app name correct + if (isset($title)) { + $urlencoded .= urlencode(urlencode($title).":"); + } + $urlencoded .= urlencode($name.'?secret='.$secret); if (isset($title)) { $urlencoded .= urlencode('&issuer='.urlencode($title)); } - return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level"; }