oauth 2.0 – How to fix 401 – unauthorized – when testing spring rest API secured with google oauth2 via postman – roles in DB – Code Utility

[

I was following this articles
https://www.javachinna.com/spring-boot-angular-10-user-registration-oauth2-social-login-part-1/

https://www.javachinna.com/spring-boot-angular-10-user-registration-oauth2-social-login-part-2/

I want to test the spring endpoints via postman, and setup below and getting token, but not sure of the roles. The roles are in DB

How can I test my rest api using postman

My endpoint is like below

@GetMapping("/todos")
    @PreAuthorize("hasRole('ADMIN')")
    public List<CourseDTO> list(@CurrentUser LocalUser user) {
        System.out.println(user);
        return myService.findAll();
    }

Websecurity config

.antMatchers(“/”, “/error”, “/api/all”, “/api/auth/“, “/oauth2/“,
“/index.html”, “/.js”, “/.js.map”, “/.css”, “/assets/img/.png”,
“/favicon.ico”).permitAll()

though I tried .antMatchers(HttpMethod.POST, "/admin/todo/**").hasRole("ADMIN")

But getting 401 unauthorized – “message”: “Full authentication is
required to access this resource”,

enter image description here

,

Set it like this and then retry :

grant_type=client_credentials

]