- Have an old Mac Laptop with an old MacOS version that you need Microsoft Office installed on (works with Intel-based Mac running High Sierra)
- Have an Office 365 License
- You attempted to install Office and, when prompted to input your account details to authenticate in each Office App, the authentication window turns blank (in my case, it occurs right after inputting the account email)
- Although it presents similiar issues when authenticating, I can't tell for sure if it works with Office 2016 (which I also installed, but moved on from before trying out this approach). This method was tested with Office 2019 alone.
- This method works for most of the apps bundled in Office 2019 (tested with Excel, Word, PowerPoint and OneNote - I think Outlook doesn't require it, although I haven't set it up). However, I couldn't get it to work for Microsoft Teams, as it seems to follow an alternate authentication approach that I haven't investigated too deeply as I wasn't invested in getting that App specifically to work.
- In its current state, this method will require you to move quickly to manually select, alter and submit the intercepted request. It may take a few attempts to do it quickly enough (from what I tested, it seems like you need to do it in under 30s). Maybe this method could be replaced by a small mitmproxy add-on to overcome this
The method involves intercepting the App request made from the authentication window (i.e. the embedded browser window that pops up when the Microsoft Office App attempts to authenticate to your Microsoft Account) that leads to the blank page, using that request URL in a browser to complete the login, capturing the result code and then forcing the authentication page window to redirect to that same code URL. In other words, we will run part of the authentication process from a separate browser in order to see it completed and then simply return the auth code to the authentication window via a specially-crafted redirect response.
Intercepting and modifying the authentication window requests may take some time to learn and to execute quickly enough. Take some time to understand how it works in order to do that, as the authentication page times out after a certain period of time without a response. I highly recommend learning the tool shortcuts to avoid wasting any time in that process.
- Have a working browser available in the machine (in my case I had to install the latest available Firefox for MacOS High Sierra)
- Download and install Office 2019 for Mac
- Here you should be able to find a version that works in your case: https://learn.microsoft.com/en-us/officeupdates/update-history-office-for-mac
- Install this proxy tool for intercepting and modifying the authentication requests: https://mitmproxy.org/
- You need to install an older version that is compatible with your macOS version: https://mitmproxy.org/downloads/
- Start up the proxy tool (in my case, it opened a Terminal window with a text-based UI)
- Enable proxy in the computer network settings (I've set it to proxy both http and https traffic via 127.0.0.1:8080)
- The tool should be showing flows in the Terminal UI
- Install the tool certificates and have the machine trust them in order to intercept and manipulate https traffic: https://docs.mitmproxy.org/stable/concepts-certificates/
- This should lead you to the following local URL, which the proxy will intercept:
mitm.it
- Remember to set this certificate to "Always Trust"
- This should lead you to the following local URL, which the proxy will intercept:
-
Select one Office App that you wish to authenticate under and start the App
- After providing your email, the authentication page should go blank when requesting the password
- Look for the last request made by the authentication window in the mitmproxy tool before it went blank. Focus on that URL with the arrow keys and hit enter to highlight the request details. Copy that URL
- In my case, the URL looked like this:
https://login.live.com/oauth20_authorize.srf?client_id=...
- After copying it from the Terminal, I also had to remove some spaces that got copied from the terminal window
- In my case, the URL looked like this:
- Disable the computer proxy setting (otherwise the next step won't work)
- Open the captured URL in a browser (I've done it with Firefox) and finish the authentication process:
-
Let's now authenticate the Office App
-
Go back to the authentication window, click back
-
In the mitm proxy UI, configure an intercept command. We'll use it to intercept and modify the response to the request that leads to the blank page this time: https://docs.mitmproxy.org/stable/mitmproxytutorial-modifyrequests/. This is the setting I used:
- Intercept, to hold back from responding to authentication requests (shortcut
i
):/oauth20_authorize.srf
- (RECOMMENDED) Filter, to ensure that only relevant flows will show up (shortcut
f
):login.live.com
- Intercept, to hold back from responding to authentication requests (shortcut
-
Run through the authentication steps for the Office App once more. Right after that, go to the mitm proxy tool UI and look for the intercepted request flow and hit enter. Intercepted request flows will appear in red
-
Within the intercepted request, modify the following response properties:
-
Once both response code and headers are altered, go back to the flow list and hit
a
to allow response through -
Take a look at the Office App authentication window - it should have been able to move forward with the authentication process. You should now have your App authenticated with your Microsoft Account.
-
You can re-use the same code URL for all Office apps you wish to authenticate to (earlier in the document I listed the Apps it worked with)
-
-
Once you're done, remove the proxy setting from your network settings and feel free to uninstall mitmproxy
-
I also recommend removing the mitmproxy certificates from your local keychain as you'll no longer need them (or, at least, set them as not trusted).
This alternate method is a slight variation of the method above that involves the aid of a mitmproxy addon to automate some of the steps. Executing this method requires some level of familiarity with the Mac Terminal application.
- Copy the
office-auth-redirect.py
addon file to the same folder where the mitmproxy application is present - To launch the proxy, open the Terminal application and head over to the folder where the mitmproxy app and proxy addon are located. Here is an example where the mitmproxy application is located in the Downloads folder:
$ cd ~/Downloads
# Assuming that mitmproxy and the pyhton addon script are here:
$ ./mitmproxy.app/Contents/MacOS/mitmproxy -s office-auth-redirect.py
- This should start the proxy with the addon script. Now, attempt to log into the Office App.
- If you have Firefox installed, this should open a Window in it where it says that you are attempting to access a page via unsafe means. Disable the proxy from the network settings and reload the page. It should get you through the steps required to authenticate to your Office 365 account (beware: it won't need to happen if you are logged into Office 365 already). You should end up in the URL with the Auth code at the end of the flow (it's a blank page, like the one shown in the steps from the regular method above). Copy that Auth code URL
- If you don't have Firefox installed, while in the mitmproxy UI, hit
E
and look for a line that starts withHead over to this URL in your browser if you haven't yet:
. Copy the URL from that line and head over to a browser with it, after disabling the proxy in the networking settings. Copy the Auth URL at the end of the authentication process.
- Re-enable the proxy in the Network settings
- Close the mitmproxy tool in the Terminal (hit
q
to quit andy
to confirm) - Open the
office-auth-redirect.py
file with a text editor (e.g. you could usevim
from the Terminal) - Add the Auth URL you acquired to the AUTH_URL variable (don't forget to retain the quotes) and save the file.
- With this done, the script will behave differently: instead of opening a browser window, it will immediately redirect authentication attempts to the appropriate Auth code URL instead.
- Restart mitmproxy with the same command line once again
- Try to authenticate into Office from the Office App once again. This time, you should see the App successfully authenticating into Office 365
Rafael, I am so grateful for your work around and very kind assistance with the process.
As you very correctly stated, this method requires very quick input from the user, to manually select, alter and submit the intercepted request. It requires a fair bit of repetitive practice to do it in under 30s.
I found that learning and practising the mitmproxy tutorial is a must as well as learning some of the keyboard short cuts.
Going through the process I had saved in a text document the Full URL with the access token.
Beware I found that after a few attempts or a restart, the values changed, to avoid frustration to novice like me, I recommend once you get lost in the process to quit all application, run Microsoft_Office_License_Removal_2.7, to clear the system.
Then start again from scratch following the full method as supplied by Rafael
One more thing, below is a summary detail of typing keys to make it clearer for all for the end sequence.
Make sure - Certificate is trusted
Proxy is enabled
Shortcut i : /oauth20_authorize.srf then Hit ENTER
shortcut f : login.live.com then Hit ENTER
Launch MS App (Excel) to validate enter user and next
Within the intercepted request, modify the following response properties:
a. Response headers (shortcut e 9 , then a to add row):
Type the word: Location then Hit TAB to move cursor under Value column
Then Paste the full URL you copied before (the one that looks like "https://login.live.com/oauth20_authorize.srf? lc=1046#access_token=..." ( easier to save it in a text document with the above command to access it quickly)
After a few seconds one the pasted text is shown
Hit ESC to stop editing it highlight the whole text in darker colour
Hit q once,
b. Response code (shortcut e c ): 302 Hit ENTER
Hit a Hit a Hit a Hit a
If done within 30 Second it activates my Excel Application, as I did do it with Excel when I checked the other MS Aps Word and PowerPoint were also activated.