How to setup Micorosoft Social Login for Spring Security

roman 0 Reputation points
2025-01-21T09:58:09.64+00:00

Hi

I would like to add a Microsoft login button to my online store, i have a spring boot backend and currently have google login implemented with spring security, I would like to have Microsoft work in the same way. I want to let any user login. My current flow is the backend receives the JWT toke, authenticates it and passes the Bearer token to the front end.

I have tried so many different ways but nothing has worked.

My understading is I have to use a /common endpoint to let any user login, but I have not been able to get this working. Only time I have been successfull is when i manually add a user to the directory but this isn't what i need.

Does anyone have any guidance as to what I should be doing?

Thanks

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,268 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Goutam Pratti 1,670 Reputation points Microsoft Vendor
    2025-01-22T23:33:28.24+00:00

    Hello @roman ,

    Thank you for reaching out Microsoft Q&A.

    I Understand that you want to setup Microsoft Social Login for Spring Security but you have been successful when you manually add a user to the directory but you want to let any user login.

    If you're using B2B collaboration, the user must be added to the tenant as a guest in order to log in to the application through Microsoft account. Without adding the user to the tenant, they cannot log in with a Microsoft account.

    To allow any user to log in with Microsoft account, you need to integrate Spring Security in Azure AD B2C tenant for the Microsoft login user flow.

    For additional information please follow the document: Microsoft Accounts for B2B Collaboration , https://learn.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-microsoft-account?pivots=b2c-custom-policy

    Hope this helps. Do let us know if you any further queries.


    Regards,
    Goutam Pratti.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.