I am configuring an OAuth2 authorization server in a Spring project. Here is configuration.
@Override
public void configure(ClientDetailsServiceConfigurer clients)
throws Exception {
clients.jdbc(dataSource)
.withClient("user")
.secret("secret")
.scopes("read", "write")
.autoApprove(true)
.authorizedGrantTypes(
"password","authorization_code", "refresh_token")
}
The problem is that each time I restart application, it tries to add those clients in database, which I don't want. I am getting the unique constraint violation exception. How can I configure it to only add the clients only if they not already exists?
Thanks.