对接Alexa后台,enable 技能时需要通过我自己做的后台Oauth服务,经常会报错
Handling error: InvalidGrantException, Invalid authorization code: Dyki6G,
有人遇到类似这样的问题吗?还是我的浏览器配置有问题呢?
配置AuthorizationServerConfiguration认证节点使用JdbcAuthorizationCodeServices服务来存储和共享授权码通过数据库。
@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter implements EnvironmentAware {
@Inject
private DataSource dataSource;
@Bean
public TokenStore tokenStore() {
return new JdbcTokenStore(dataSource);
}
// JdbcAuthorizationCodeServices stores authentication codes in a database.
@Bean
public JdbcAuthorizationCodeServices jdbcAuthorizationCodeServices() {
return new JdbcAuthorizationCodeServices(dataSource);
}
@Inject
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.tokenStore(tokenStore())
.reuseRefreshTokens(false)
.authenticationManager(authenticationManager)
.authorizationCodeServices(jdbcAuthorizationCodeServices());
}
}
创建oauth_code表
CREATE TABLE oauth_code (
code VARCHAR(256), authentication LONGVARBINARY
);