【问题标题】:Deployable Spring Boot Wars OAuth2 Denied Exception可部署的 Spring Boot Wars OAuth2 拒绝异常
【发布时间】:2017-06-05 14:44:31
【问题描述】:

我有三个 spring boot 应用程序,一个是 derby spring boot,另外两个具有 OAuth2 (org.springframework.security.oauth2),一个具有 OAuth2 客户端,另一个具有 OAuth2 服务器。我已将它们转换为可部署的战争并将它们部署到 tomcat,它们似乎运行良好。除了 OAuth2,它似乎在可部署的战争中失败了。我看到了这个错误:

org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Error requesting access token.
at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:145)
at org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider.obtainAccessToken(ClientCredentialsAccessTokenProvider.java:44)
at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainNewAccessTokenInternal(AccessTokenProviderChain.java:148)
at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainAccessToken(AccessTokenProviderChain.java:121)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.acquireAccessToken(OAuth2RestTemplate.java:221)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:173)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.createRequest(OAuth2RestTemplate.java:105)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:648)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:128)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
at org.springframework.web.client.RestTemplate.headForHeaders(RestTemplate.java:336)

我已经调试了可执行文件和可部署文件,我唯一发现的是,在可执行文件战争中,OAuth2AccessToken 有一个值,但在 tomcat 中的部署战争中,OAuth2AccessToken 为空。

我可以使用curl 获取令牌,并且我已检查应用程序中的 url 是否正确。

我还尝试在单独的 tomcat 中部署 derby spring boot,这使得 OAuth2 开始工作,不知道为什么。

我不确定为什么会发生这种情况,因为战争是一样的。我在tomcat中缺少一些配置吗?

或者可能与部署在 tomcat 中的类有冲突?还是 tomcat 类路径?

【问题讨论】:

    标签: java spring tomcat oauth-2.0 spring-security-oauth2


    【解决方案1】:

    我曾经遇到过类似的问题。我在 AWS 上部署了 Spring Boot 应用程序,但遇到了同样的错误。我正在部署 .war 文件并在 AWS 上单独运行 Tomcat。我通过部署本身包含 tomcat 服务器的 .jar 文件来修复错误。不确定场景是否相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-25
      • 2019-01-20
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 2020-04-14
      • 2021-04-15
      • 1970-01-01
      相关资源
      最近更新 更多