# Auth0-spring-security-api-sample not working

**URL:** <https://community.auth0.com/t/auth0-spring-security-api-sample-not-working/6494>\
**Category:** Get Help\
**Tags:** auth0-api-sample\
**Created:** [May 5, 2017, 5:35am UTC](https://community.auth0.com/t/auth0-spring-security-api-sample-not-working/6494 "2017-05-05T05:35:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![palak.debnath](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@palak.debnath](https://community.auth0.com/u/palak.debnath)\
**Post date:** [May 5, 2017, 5:35am UTC](https://community.auth0.com/t/auth0-spring-security-api-sample-not-working/6494/1 "2017-05-05T05:35:34Z")

</div>

Hello,

I’m trying to execute following project with the id\_token token value which I got by calling [https://xxx.auth0.com/oauth/ro](https://xxx.auth0.com/oauth/ro) endpoint -

> **[auth0-spring-security-api-sample/01-Authorization at master ·...](https://github.com/auth0-samples/auth0-spring-security-api-sample/tree/master/01-Authorization)**
>
> master/01-Authorization

But it is giving 401 Unauthorized while calling [http://localhost:3001/photos](http://localhost:3001/photos) endpoint (GET). Can you please help me out? Where I’m making mistake? Can you provide some sample link?

Thanks in advance.

-Palak

---

<div class="post-metadata">

**Author:** ![palak.debnath](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@palak.debnath](https://community.auth0.com/u/palak.debnath)\
**Post date:** [May 5, 2017, 6:12am UTC](https://community.auth0.com/t/auth0-spring-security-api-sample-not-working/6494/2 "2017-05-05T06:12:12Z")

</div>

I found there was issue with JsonWebToken Signature Algorithm setting. Now I made it HS256 and from AppConfig.java file also using .forHS256(apiAudience, issuer, b), but I’m getting following error while hitting localhost:3001/photos endpoint -

{  
“timestamp”: 1493939218189,  
“status”: 403,  
“error”: “Forbidden”,  
“message”: “Access is denied”,  
“path”: “/photos”  
}

My configure() method in AppConfig.java file looks like following -

```
@Override
protected void configure(HttpSecurity http) throws Exception {
	
	byte] b = secrete.getBytes(StandardCharsets.UTF_8);
	
    JwtWebSecurityConfigurer
             .forHS256(apiAudience, issuer, b)
            .configure(http)
            .authorizeRequests()
            .antMatchers(HttpMethod.GET, "/login").permitAll()
            .antMatchers(HttpMethod.GET, "/photos/**").hasAuthority("read:photos")
            .antMatchers(HttpMethod.POST, "/photos/**").hasAuthority("create:photos")
            .antMatchers(HttpMethod.PUT, "/photos/**").hasAuthority("update:photos")
            .antMatchers(HttpMethod.DELETE, "/photos/**").hasAuthority("delete:photos")
            .anyRequest().authenticated();
}

```

Can you please what I’m doing wrong?

Thanks in advance.

-Palak

---

<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:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/auth0-spring-security-api-sample-not-working/6494/3 "2018-03-02T05:53:43Z")

</div>


