šŸ†˜ OAuth2 Proxy + NGINX Proxy Manager + Paperless-ngx

Hello, I require help connecting my 4x microsoft and 1x gmail e-mail account in Paperless-ngx using oAuth2.0.

I want to be able to have paperless-ngx pulling my mail documents and organizing them for me.

I’m using MFA protected mail accounts that’s why the usual connection method doesn’t work and disabling MFA is not an option for me.

My setup is Homeassistant OS on a raspberry 4 and I have installed Nginx Proxy Mangager and Paperless-ngx as an addon.

I don’t own a domain where I could configure DNS Records and I’m using the DDns from AVM Fritzbox.

Since I can’t configure paperless to be accessible via ā€œpaperless.xyz.myfritz.net:8123ā€ I have made it accessible behind nginx using ā€œxyz.myfritz.net:8123/paperlessā€.

I have created an azure trial with my main account to be able to register an app to receive the ā€œPAPERLESS_OUTLOOK_OAUTH_CLIENT_IDā€ ā€œPAPERLESS_OUTLOOK_OAUTH_CLIENT_SECRETā€ and set the PAPERLESS_OAUTH_CALLBACK_BASE_URL like https://xyz.myfritz.net:8123/paperless

the redirect_url in azure is https://xyz.myfritz.net:8123/paperless/api/oauth/callback/

This enabled the microsoft connect button in paperless-ngx

At this point I’m stuck at the following point when the redirect should happen:

I think this must have something to do with my Nginx Reverse Proxy and I’ve looked up many posts from other people having the same problem but I’ve seen no real solution to that.

The only thing that looked remotely promising so far was setting up an OAuth2 Proxy

However since this isn’t available as an addon I wasn’t really sure on how to set this up in homeassistant.

Does anybody know a solution for my problem or maybe my setup should be revised completely?

The issue was living shorter than I expected it to be.

I managed to fix it myself after reading through the redirect_url which paperless-ngx has generated for microsoft, I saw that there was an issue with the url containing /paperless twice

xyz.myfritz.net/paperless/paperless/api/oauth/callback/

The config part in paperless-ngx which I took from another guide which obviously didn’t make sense with my nginx path and resulted in a wrong redirect_url path:

PAPERLESS_OAUTH_CALLBACK_BASE_URL=https://xyz.myfritz.net/paperless

Removing the /paperless from this path fixed the issue for me.

I hope this helps anyone else stumbling upon this in the future.