How to expose custom rest methods to oauth2 client ? using user credential?

given the code

my goal is to expose /api/authhello/sayhello
to a Outh2 client . How to do this ?

Generally I’d like to use my application as a pure Rest Api server.
Is there any example project or technical article to read ?

Can I use Jmix User to login after client outh2 is authenticated ?

‘’’
@RestController
@RequestMapping("/api/authhello")
public class AuthHello {
@Autowired
private DataManager dataManager;
@GetMapping(value = “/sayhello”)
public String hello() {
return “Hello World RESTful with Auth”;
}
}
‘’’

I tried

‘’’
application.properties
spring.security.oauth2.authorizationserver.client.myclient.registration.client-id=xxxxx
spring.security.oauth2.authorizationserver.client.myclient.registration.client-secret={noop}yyyyy
spring.security.oauth2.authorizationserver.client.myclient.registration.authorization-grant-types=client_credentials
scheme
spring.security.oauth2.authorizationserver.client.myclient.registration.client-authentication_methods=client_secret_basic
spring.security.oauth2.authorizationserver.client.myclient.token.access-token-format=reference
spring.security.oauth2.authorizationserver.client.myclient.token.access-token-time-to-live=24h
jmix.authserver.client.myclient.client-id = snrdnxpvvb
jmix.authserver.client.myclient.resource-roles = custom-rest-role
jmix.rest.authenticated-url-patterns=/api/authhello/**
‘’’

and
‘’’

@Configuration
public class AppSecurityConfiguration {
@Bean
@Order(JmixSecurityFilterChainOrder.CUSTOM + 1)
SecurityFilterChain publicFilterChain02(HttpSecurity http) throws Exception {
http.securityMatcher( “/api/authhello/**” ).authorizeHttpRequests(authorize → authorize.anyRequest().authenticated());
return http.build();
}
}
‘’’

but …
I can get the Oauth2 token by “postman call”

‘’’

POST http://localhost:8080/oauth2/token
{
“access_token”: “zzzzzzzzzzzzzzzzzzzzz”,
“token_type”: “Bearer”,
“expires_in”: 86399
}
‘’’

when I call “sayhello” from postman

‘’’

http://localhost:8080/api/authhello/sayhello
bearer token “zzzzzzzzzzzzzzzzzzzzz”
‘’’
I obtan

‘’’

{
“timestamp”: “2024-09-19T08:34:15.578+00:00”,
“status”: 403,
“error”: “Forbidden”,
“path”: “/api/authhello/sayhello”
}
‘’’