Java 如果客户端中有几个指定的大类型,将使用哪种授予类型?
我有一个Oauth服务器。我使用InMemoryClientDetailsServiceBuilder为客户提供服务。但是,即使我有很多授权类型,我的oauth客户机和服务器也总是使用授权代码大类型。为什么? 代码示例:Java 如果客户端中有几个指定的大类型,将使用哪种授予类型?,java,spring,spring-security,oauth-2.0,spring-security-oauth2,Java,Spring,Spring Security,Oauth 2.0,Spring Security Oauth2,我有一个Oauth服务器。我使用InMemoryClientDetailsServiceBuilder为客户提供服务。但是,即使我有很多授权类型,我的oauth客户机和服务器也总是使用授权代码大类型。为什么? 代码示例: @Configuration @EnableAuthorizationServer public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { @Autow
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authenticationManager);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("myClient1")
.secret("dsfsdfewrewr324")
.authorizedGrantTypes("authorization_code", "refresh_token", "password")
.authorities("USER", "ADMIN")
.scopes("read", "write")
.autoApprove(true);
}
}
我找到了答案。它取决于客户端授予类型属性 我们可以像这样在应用程序道具中配置它
my.client.clientId: myClient1
my.client.clientSecret: dsfsdfewrewr324
my.client.accessTokenUri: http://localhost:8789/server/oauth/access_token
my.client.userAuthorizationUri: http://localhost:8789/server/oauth/authorize
my.client.grantType=implicit
my.resource.userInfoUri: http://localhost:8789/server/api/me
但是我们可以将grantType属性保留为空,因为一些OAuth2ProtectedResourceDetails实现(如AuthorizationCodeResourceDetails)会填充它
我总是会出错,因为我总是使用AuthorizationCodeResourceDetails,而不是隐式资源详细信息
@Bean
@ConfigurationProperties("my.client")
public OAuth2ProtectedResourceDetails client() {
return new AuthorizationCodeResourceDetails();
}