Using a spring-boot-starter-oauth2-resource-server to connect with Google oauth2

Viewed 423

i am working on a java spring boot server which should work as a ressource server and should connect with google authentication.

spring.security.oauth2.client.registration.google.client-id=#google id
spring.security.oauth2.client.registration.google.client-secret=#google secret
spring.security.oauth2.resourceserver.jwt.issuer-uri=https://accounts.google.com/o/oauth2/auth
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://www.googleapis.com/oauth2/v1/certs

I also created a websecurity:

@Configuration
public class WebSecurity extends WebSecurityConfigurerAdapter {


@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity
            .authorizeRequests().anyRequest().permitAll()
            .and()
            .oauth2ResourceServer()
            .jwt();
 }

I used the dependencies:

 implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'

   

But it is not working, everytime i got an 401 Unauthorized Response.

As a client i used postman with basic2Auth and i could create a token. What should i do next?

Do i missunderstood anything?

0 Answers
Related