Microsoft auth by connected app -> How to add login button?

Following the instruction ( [Tutorial] Connecting Frappe/ERPNext to Microsoft 365 mail services OAuth - Frappe Framework - Frappe Forum), I was able to add Microsoft Auth to my ERPNext websites.

To further test, I’d like to add this login option available on the login page, but have no clue how to do so.

Go to the Social Login Key Doc

Enable the Social login

@python_a Thx. But This looks like I set up new auth, isn’t it?
Shouldn’t I add Client URL’s redirect URL to Azure’s Authentication Web Redirect URIs?

This has two bounded issues to me.

  1. The client URLs’ Redirect URL looks following
  • /api/method/frappe.integrations.oauth2_logins.login_via_office365

Then, when I do try login via Office365, as expected I get an error that the redirect url is not added to Azure registration.

The issue here is that
A. It has ‘http’, instead of ‘https’, so I cannot add this URL to Azure’s redirect URI list.
B. I also had to change the ‘http’ to ‘https’ for Microsoft 365 mail OAuth at DB level in tabConnectedApp, I was going to do the same for Social Auth, but the Social Auth’s redirect URL is relative, so I cannot change the value.

I have proxy Nginx server that terminates SSL handshake and forward the traffic to backend by http. Changing this for two ERPNext tenants with different domains will create another problems with double SSL auth. There must be easier solution.

I manually changed the Redirect URL in tabSocialLoginKey, then I end up with email not verified with Office 365 error.

I followed instructions from this link - Login with Office 365: Email not verified - Integration - Frappe Forum, and added optional claim for email for all three token types (ID, Access, SAML).

Now it works.

Add 2 redirect uri on azure end, you can use same client.

You’ll need to add same client in 2 places. Only redirect uri is different.

Post about host_name How to configure microsoft account by oauth in erpnext - #12 by revant_one

Yup I can see both works with multiple Redirect URLs. I actually use the same tactic with multiple applications in my websites. Adding two more wasn’t an issue.

Try This Detailed Process ,if you still needs any help

https://www.notion.so/Add-Social-Login-Active-Directory-122743464d648044b580f6e35e42525d