- apktool
zipalignandapksignerand from the Android SDK Build Toolskeytoolfrom a Java JRE or JDK
-
Get the APK of the current MS Teams app (e.g. by copying it from your phone or downloading from APKMirror). These instructions were tested with version
1416/1.0.0.2022394701, and assume it is saved asteams.apk. -
Extract the APK:
apktool -r d teams.apk -
Find the
WebViewAuthorizationFragmentclass. In the current version it is undersmali_classes3/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.smali. -
In this class, in the
setUpWebViewfunction, the User-Agent for the WebView is set like this:invoke-virtual {v0, p1}, Landroid/webkit/WebSettings;->setUserAgentString(Ljava/lang/String;)VRight before this, add the following line to override the User-Agent:
const-string p1, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"(or another recent desktop User-Agent)
-
In theThis seems to be no longer necessary in the newest version of the Teams app. Yay! 🥳res/rawdirectory, in each of the filesmsal_config.json,msal_config_opt_disabled.json,msal_enterprise_config.jsonandmsal_enterprise_config_opt_disabled.json, set thebroker_redirect_uri_registeredsetting tofalse. This is needed because the modified APK will be signed with a different key. -
Rebuild the APK:
apktool b teams -o teams_mod.apkIf you need to install the app alongside the official Teams app, change the package name now and rename conflicting content providers in the Manifest (e.g. using this tool):
git clone git@github.com:johan12345/ApkRename.git ApkRename/apkRename.sh teams_mod.apk com.microsoft.teams.mod! -
Zipalign:
zipalign -f -p 4 teams_mod.apk teams_mod_zipalign.apk -
Sign the APK:
keytool -genkey -keystore keys.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias Teams apksigner sign --ks keys.keystore --out teams_mod_signed.apk teams_mod_zipalign.apk -
Install the resulting
teams_mod_signed.apkon your Android device. If you did not change the package name above, you will need to uninstall the official version of Teams first due to the different signature.
The reason why I want to try this is with our teams deployment, authentication works only from within Intranet. With my smartphone I cannot enter Intranet (no VPN). I can do a trick with a proxy running on my company laptop. It accepts http requests from my mobile (in the same Wifi network) and forwards it via VPN to companies proxy. So theoretically (and in the past practically as well) I can log in. After successful login a token is created and Teams will work without any connection to companies Intranet.
However what company has changed is that during login, untouched Teams app notices that I am coming from a mobile device and claims I need to install Intune etc. which I do not want...