Skip to content
Advertisement

Getting an exception when tried to implement Azure AD authentication and authorization in Spring Boot

I receive the following error:

JavaScript

Even though I’ve provided the client ID in application.properties.

I followed the following link: https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory

POM:

JavaScript

MAIN:

JavaScript

CONTROLLER

JavaScript

APPLICATION.PROPERTIES

JavaScript

I updated my POM with

JavaScript

The new error after updating POM:

JavaScript

I’ve updated my POM, now it is building fine, but on login I’m getting AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: ’18da6914-……………………….’. I added the following redirect URI: localhost:8080, localhost:8080/login/oauth2/code.

As I’m completely new to this, I would be thankful for any help.

Advertisement

Answer

Your code looks correct. But as the error shows “nested exception is java.lang.IllegalStateException: Client id must not be empty.”, you need to check the application.properties again and make sure it’s correct.

And the sample needs three dependencies(spring-boot-starter-oauth2-client, spring-boot-starter-web, azure-spring-boot-starter-active-directory), you could try to update your pom with the newer version.

There is my code following the tutorial.

Main:

JavaScript

Controller:

JavaScript

application.properties:

JavaScript

application.properties

Test result:

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement