gpt4 book ai didi

java - 可部署的 Spring Boot Wars OAuth2 拒绝异常

转载 作者:行者123 更新时间:2023-11-28 23:20:59 25 4
gpt4 key购买 nike

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

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)

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

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

我还尝试在单独的 tomcat 中部署 derby spring boot,这使得 OAuth2 开始工作,但不确定原因。

我不确定为什么会这样,因为 war 是一样的。我是否缺少 tomcat 中的某些配置?

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

最佳答案

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

关于java - 可部署的 Spring Boot Wars OAuth2 拒绝异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43938540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com