配置:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
PasswordEncoder passwordEncoder = PasswordEncoderFactories
.createDelegatingPasswordEncoder();
clients
.jdbc(dataSource).passwordEncoder(passwordEncoder);
// .inMemory()
// .withClient("client2").secret(PasswordEncoderFactories.createDelegatingPasswordEncoder().encode("123456"))
// .authorizedGrantTypes("authorization_code", "refresh_token").redirectUris("http://localhost:8082/client2/login")
// .scopes("email", "profile")
// .autoApprove(true);
}
当我使用JdbcClientDetailsService
并通过基本身份验证请求http://localhost:8080/uaa/oauth/token_key
时,我得到401代码。
但是当我使用InMemoryClientDetailsService
时,它可以工作。
Sql:
create table oauth_client_details (
client_id VARCHAR(256) PRIMARY KEY,
resource_ids VARCHAR(256),
client_secret VARCHAR(256),
scope VARCHAR(256),
authorized_grant_types VARCHAR(256),
web_server_redirect_uri VARCHAR(256),
authorities VARCHAR(256),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
additional_information VARCHAR(4096),
autoapprove VARCHAR(256)
);
数据:
'client2', '', '{bcrypt}$2a$10$d1W72IIEfPvYh36ZxRSrMOGXY1PMW1T8yXL2OVBkrTc6Zofqs90VG', 'email,profile', 'authorization_code,refresh_token', 'http://localhost:8082/client2/login', '', NULL, NULL, '{}', 'profile,email'
版本:
spring-boot:2.1.3.RELEASE
spring-security-oauth2-autoconfigure:2.1.3.RELEASE