我尝试修改现有示例 - Tonr2 和 Sparklr2。我还查看了基于 Spring Boot Spring Boot OAuth2的本教程。我尝试像在 Tonr2 示例中那样构建应用程序,但没有首次登录(在 tonr2 上)。我只需要在 Sparklr2 端进行一个身份验证。我这样做:
@Bean
public OAuth2ProtectedResourceDetails sparklr() {
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
details.setId("sparklr/tonr");
details.setClientId("tonr");
details.setTokenName("oauth_token");
details.setClientSecret("secret");
details.setAccessTokenUri(accessTokenUri);
details.setUserAuthorizationUri(userAuthorizationUri);
details.setScope(Arrays.asList("openid"));
details.setGrantType("client_credentials");
details.setAuthenticationScheme(AuthenticationScheme.none);
details.setClientAuthenticationScheme(AuthenticationScheme.none);
return details;
}
但我有Authentication is required to obtain an access token (anonymous not allowed)
。我检查了这个问题。当然,我的用户是匿名的——我想登录 Sparklr2。另外,我尝试了这个bean的不同设置组合,但没有什么好处。如何解决?如何让它按我的意愿工作?