I have recently encountered some problems integrating Azure AD. The main problem is login. If you are confused about the official document, hopefully this can help you .
App Registrations
Firstly, you must have a App Registrations. How to register a new App? you can do as flows:
Create a new App registrations
you can search key words, such as App Registrations
in the top search blank and click the function button named App Registrations
below Services. just show in the pic.
then select New registration
to create a new one.(I don`t have the access to create it in my group, but I think it is ok to skip these parts.)
you may need to fill some blank info, you can refer official document steps:
- In the Name section, enter a meaningful application name that will be displayed to users of the app, for example java-spring-webapp-auth.
- Under Supported account types, select Accounts in this organizational directory only.
- In the Redirect URI (optional) section, select Web in the combo-box and enter the following redirect URI: http://localhost:8080/login/oauth2/code/.
Select Register
to create the application.
You also need to create secret key :
You’ll need this key later in your code’s configuration files. This key value will not be displayed again, and is not retrievable by any other means, so make sure to note it from the Azure portal before navigating to any other screen or blade.
Build App
You can download code demo from : github repo
Configure the webApp app (java-spring-webapp-auth) to use your app registration. Open the project in your IDE(Vs code or Idea) to configure the code.
Configure the webApp app (java-spring-webapp-auth) to use your app registration
- Open the src\main\resources\application.yml file.
- Find the key Enter_Your_Tenant_ID_Here and replace the existing value with your Azure AD tenant ID.
- Find the key Enter_Your_Client_ID_Here and replace the existing value with the application ID (clientId) of java-spring-webapp-auth app copied from the Azure portal.
- Find the key Enter_Your_Client_Secret_Here and replace the existing value with the key you saved during the creation of java-spring-webapp-auth copied from the Azure portal.
Other Important Settings
If you have finished all of steps and the login action is fail just like the pic:
I think there must be some other setting in Azure AD get wrong configurations. You may try to update these settings:
- config redirect urls
copy the url and configure it followed the pic guide and then try to login again :
Result: Success View
Hope this can help you ! Any future questions can have a private communication with me.😘