# Configure Spring boot app as resource server to validate access token from AUth0

**URL:** <https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, quickstarts-other\
**Created:** [April 28, 2023, 8:45pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779 "2023-04-28T20:45:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenobago](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenobago/32/46771_2.png) [@kenobago](https://community.auth0.com/u/kenobago)\
**Post date:** [April 28, 2023, 8:45pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779/1 "2023-04-28T20:45:14Z")

</div>

I’m using Spring boot 2.7.8v to integrate Oauth using Auth0. i have followed exactly the steps from the [docs](https://auth0.com/docs/quickstart/backend/java-spring-security5/01-authorization?_gl=1*1j23r35*rollup_ga*MTI2ODYzMzc5NS4xNjgyNjA2MTg3*rollup_ga_F1G3E656YZ*MTY4MjcwNjEwNC45LjEuMTY4MjcwNjMyMy40OS4wLjA.&_ga=2.133660750.1768498153.1682606187-1268633795.1682606187#configure-the-resource-server) to implement authentication in my app but i keep getting IllegalAurgmentException. here is the execption:

```auto
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-04-28 13:41:42.747 ERROR 25340 --- [main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.security.oauth2.resourceserver.jwt.issuer-uri' in value "${spring.security.oauth2.resourceserver.jwt.issuer-uri}"
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.8.jar:2.7.8]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.8.jar:2.7.8]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.8.jar:2.7.8]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.8.jar:2.7.8]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.8.jar:2.7.8]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.8.jar:2.7.8]
	at com.kentechies.youtube.youtubeclone.YoutubeCloneApplication.main(YoutubeCloneApplication.java:17) ~[classes/:na]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.security.oauth2.resourceserver.jwt.issuer-uri' in value "${spring.security.oauth2.resourceserver.jwt.issuer-uri}"
	at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) ~[spring-core-5.3.25.jar:5.3.25]
	at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-5.3.25.jar:5.3.25]
	at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239) ~[spring-core-5.3.25.jar:5.3.25]
	at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-5.3.25.jar:5.3.25]
	at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:191) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:936) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1332) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.25.jar:5.3.25]
	... 17 common frames omitted

```

My Application.yaml:

```auto
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: https://<domain>auth0.com/
          audiences: http://localhost:8080/
  data:
    mongodb:
      host: localhost
      port: 27017
      database: clonedb

cloud:
  aws:
    stack:
      auto: false

```

The class to validate JWT:

```auto
@EnableWebSecurity
public class SecurityConfig {

    @Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
    private String issuer;

    @Value("${spring.security.oauth2.resourceserver.jwt.audiences}")
    private String audiences;

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated())

                .sessionManagement()
                        .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                                .and()
                .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
      return httpSecurity.build();
    }

    @Bean
    JwtDecoder jwtDecoder() {
        NimbusJwtDecoder jwtDecoder = JwtDecoders.fromOidcIssuerLocation(issuer);

        OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(audiences);
        OAuth2TokenValidator<Jwt> withIssuer = JwtValidators.createDefaultWithIssuer(issuer);
        OAuth2TokenValidator<Jwt> withAudience = new DelegatingOAuth2TokenValidator<>(withIssuer, audienceValidator);

        jwtDecoder.setJwtValidator(withAudience);

        return jwtDecoder;
    }

```

Anyone with the solution should please help. i will be grateful.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 3, 2023, 3:11pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779/3 "2023-05-03T15:11:00Z")

</div>

Hi @kenobago,

This exception indicates the application is not able to resolve the config from your `application.yaml` file.

This SO thread has some strategies you can try: [yaml - getting Could not resolve placeholder while reading yml values in spring boot - Stack Overflow](https://stackoverflow.com/questions/70906457/getting-could-not-resolve-placeholder-while-reading-yml-values-in-spring-boot)

---

<div class="post-metadata">

**Author:** ![kenobago](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kenobago/32/46771_2.png) [@kenobago](https://community.auth0.com/u/kenobago)\
**Post date:** [May 3, 2023, 3:40pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779/4 "2023-05-03T15:40:46Z")

</div>

Thanks @dan.woda  
it got fixed after using [yamllint](https://www.yamllint.com/) to validate the `application.yam`l file

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 3, 2023, 3:41pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779/5 "2023-05-03T15:41:05Z")

</div>

Awesome. Thanks for the update!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 17, 2023, 3:41pm UTC](https://community.auth0.com/t/configure-spring-boot-app-as-resource-server-to-validate-access-token-from-auth0/105779/6 "2023-05-17T15:41:34Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
