spring-boot - 我可以在我的 Spring Boot 应用程序中使用来自谷歌的 id_token 吗?
问题描述
当我使用 google oauth2 保护我的 Spring Boot 应用程序时,是否可以捕获 ID 令牌?
当我使用邮递员 + keycloak 获取访问令牌时,我会得到以下信息:
{
"access_token": "eyJhbGc...",
"expires_in": 3600,
"refresh_expires_in": 8640,
"refresh_token": "eyJhbG...",
"token_type": "Bearer",
"id_token": "eyJhbG...",
"not-before-policy": 0,
"session_state": "779e9b7b-ae44-...",
"scope": "openid email profile"
}
有id_token。用户使用谷歌登录后,是否可以在我的 Spring Boot 应用程序中获取此 id_token?
我想要可以使用但来自谷歌的类似 ID 令牌。我有一个这样的控制器,但没有发现我是否可以拥有这个 ID 令牌并使用它的声明。
@GetMapping("/userinfo")
public String userinfo() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
System.out.println(authentication.getAuthorities().toString());
return "Userinfo...";
}
提前致谢
解决方案
推荐阅读
- shell - 在shell脚本中,从while循环中的文件读取后无法访问外部变量
- javascript - 如何将剃刀计数器传递给 onkeyup javascript 函数
- javascript - JSPM 私有注册表配置
- xquery - XQuery 集合 - 无法从目录中获取多个文件
- android - 带有视图列表的链式动画 RxJava2 Android
- bash - 从 bash 循环中的 V_${i}_T 变量名中提取指针
- reactjs - 如何在 React.js 中访问另一个同级 DOM 元素
- ios - Swift:弹出窗口和 ViewDidAppear 等
- http - 无法从命令行访问 go 服务器/将 Web 服务器逻辑添加到现有代码
- scala - 根据 Scala Spec 中的对象定义,导入的对象是永久隐藏的警告