问题描述
我正在使用
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
<version>5.1.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
<version>5.1.13.RELEASE</version>
</dependency>
我没有使用最新版本,因为我的启动是 2.1.2.RELEASE
。
我有几乎与 this blog(bealdung) 类似的架构,它今天可以使用。
我没有更改任何代码,但在向谷歌发送数据后突然打印如下错误。 (未知主机错误)
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for "https://www.googleapis.com/oauth2/v4/token": www.googleapis.com; nested exception is java.net.UnkNownHostException: www.googleapis.com
Error 的位置是 getTokenResponse
中的 org.springframework.security.oauth2.client.oidc.authentication.OidcAuthorizationCodeAuthenticationProvider.authenticate
语句。
据我检查,我设置的值(profile.yml 中的 client_id
和 client_secret
)在 OAuth2AuthorizationRequest authorizationRequest
实例中。
我怀疑机密已过期,因此我在 Google Api 控制台中更新了我的机密,但还没有找到运气。我已经在这个问题上花了将近 3 个小时所以任何建议将不胜感激。
TLDR;
- 从 https://www.googleapis.com/oauth2/v4/token 中查找 UnkNownHostException 的原因
- 突然,oauth2 谷歌登录抛出 UnkNownHostException
- 我在 API 控制台中更改了密码,但还是一样
- client_id、client_secret 在 OAuth2AuthorizationRequest 实例中
附注。 正如我所说,它以前有效,所以当然我在 Google Api 控制台中有正确的设置(uri 和授权的 uri,我的意思是)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)