我正在学习开发Spring应用程序+ Angular。我的访问令牌有问题。当我尝试以“医生”角色登录到应用程序时,出现错误:
o.s.s.o.p.token.store.JdbcTokenStore: Failed to find access token for token de987761-21bf-43ff-ae34-aa969d5b8958
这是我的OAuth配置代码:
@Configuration
@EnableAuthorizationServer
public class AuthServerOAuth2Config extends AuthorizationServerConfigurerAdapter {
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Autowired
private DataSource dataSource;
@Override
public void configure(final AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer
.tokenKeyAccess("permitAll()")
.checkTokenAccess("isAuthenticated()");
}
@Override
public void configure(ClientDetailsServiceConfigurer configurer) throws Exception {
configurer
.inMemory()
.withClient("healthapp")
.secret(passwordEncoder.encode("HeAltH@!23"))
.authorizedGrantTypes("password","authorization_code","refresh_token")
.scopes("read,write,doctor")
.accessTokenValiditySeconds(3600)
.refreshTokenValiditySeconds(36000)
.autoApprove(true);
}
@Override
public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
final TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer()));
endpoints.tokenStore(tokenStore())
.tokenEnhancer(tokenEnhancerChain).authenticationManager(authenticationManager);
}
@Bean
@Primary
public DefaultTokenServices tokenServices() {
final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setSupportRefreshToken(true);
return defaultTokenServices;
}
@Bean
public TokenEnhancer tokenEnhancer() {
return new CustomTokenEnhancer();
}
@Bean(name="tokenStore")
public TokenStore tokenStore() {
return new JdbcTokenStore(this.dataSource);
}
整个项目: https://github.com/Manvas/repository
可能是什么问题?