Endpoint '...' method '...' request cannot be accessed, reason: 'Access denied'"

Error: {“message”:“Endpoint ‘BarAdminEndpoint’ method ‘addOrUpdateBar’ request cannot be accessed, reason: ‘Access denied’”}

even though user has the required role.

UserDetailsServiceImpl:

    @Override
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
...
        if (users.isEmpty()) {
            System.err.println("No user present with username: " + username);
            throw new UsernameNotFoundException("No user present with username: " + username);
        } else {
            User user = users.get(0);
            return new org.springframework.security.core.userdetails.User(user.email, user.hashedPassword,
                    getAuthorities(user));
        }
    }

    private static List<GrantedAuthority> getAuthorities(User user) {
        List<GrantedAuthority> list = new ArrayList<>();
        list.add(new SimpleGrantedAuthority(""+user.role)); // Roles are 0 for User and 1 for Admin
        return list;
    }

BarAdminEndpoint:

@Endpoint
@RolesAllowed(AuthenticatedUser.ROLE_ADMIN) // Is "1" string
public class BarAdminEndpoint {

    public Bar addOrUpdateBar(Bar bar){
        ...
    }

}

“0” or “1” doesn’t sound like valid role names.

must it start with ROLE_?

for example ROLE_1

or ROLE_0

Yeah that’s the default role prefix in spring.

ok will give that a try, thanks