在angular中使用授权码grant时,如何使用spring-security-oauth2-client获取和维护o


How can I get the token to the front end angular application after successful redirection to the index.html page happens like
1. I have used 
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
in my pom.xml
2. then I have added required properties in my application.properties file
3. I built the angular files and placed them under resources/static folder

现在,重定向到auth服务器和回调到应用程序都成功了,但如何获得oauth2令牌并存储在angular应用程序中,这将有助于进一步调用

如果您有一个Angular应用程序,那么它就是客户端。它应该使用angular auth-oidc客户端或类似的客户端:

  • 登录用户
  • 处理往返授权服务器的重定向
  • 交换访问令牌的授权码
  • 访问令牌刷新
  • 将带有访问令牌的授权标头添加到发送到已配置的安全路由的请求中

Spring REST API应用程序是资源服务器。它应该依赖于spring-boot-starter-oauth2-resource-server,而不是spring-boot-starter-oauth2-client。有关配置spring资源服务器的更多详细信息,请参阅spring-boot-doc或查看这些教程。

最新更新