OAUTH 2.0 does not work

Hi.
I'm trying to integrate the Identity Manager Web Portal with Microsoft Azure using OAuth 2.0. Basically when opening the web portal the user will be directed to the Azure login screen and when logging in the user will return to the web portal page. I configured an Identity Provider in Designer and an OAuth 2.0 application and applied it to the Web Portal. Azure is also prepared to receive Web Portal redirects. The problem is that when logging into the Microsoft page, the browser makes several redirects and finally displays the error: “ERR_TO_MANY_REDIRECTS”. This happens when I use the URL “http://localhost/IdentityManager” and when I use a URL generated by Ngrok (with HTTPS).
Using the Web Portal URL, the error occurs: "AADST117: The reply uri specified in the request is not a secure scheme"
How can I solve this problem?