Spring:如何从Postman获取Oauth2令牌?

问题描述 投票:0回答:1

我已经按照这个spring-security-oauth-example创建了Oauth2服务器。如何从 Postman 获取 Oauth2 令牌?

这是资源服务器的代码,这是 授权服务器配置。

我想了解如何从 Postman 获取 clientid = "ClientId" 的 Oauth2 令牌?下面这些代码的含义是什么:

public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {

        security.tokenKeyAccess("permitAll()")
                .checkTokenAccess("isAuthenticated()");
    }

    public class ResourceServerConfig extends WebSecurityConfigurerAdapter {


        http.requestMatchers()
                .antMatchers("/login", "/oauth/authorize") //what does this do

application.properties 有

 server.port=8081 
 server.context-path=/auth security.basic.enable=false
java spring oauth-2.0 spring-oauth2
1个回答
4
投票

在 Postman 中设置 OAuth 2.0 令牌的步骤。

  1. 打开邮递员。

  2. 创建一个新请求。单击“授权”选项卡。截图如下:

  1. 选择身份验证的
    Type
    为OAuth 2.0。截图如下:

  1. 现在,单击“获取新的访问令牌”。它将弹出并显示如下:

  1. 输入所需的详细信息,例如客户端 ID、客户端密钥、回调 URL、身份验证 URL、访问令牌 URL 等。

因此,我添加了一些有用的资源来帮助您了解 OAuth 2.0 类型。

  1. OAuth 2.0 授权框架 - 这将让您了解什么是 OAuth 2.0 授权框架?

上述链接的屏幕截图:Oauth 2.0 授权框架的外观。

  1. 一些视频讲座可以直观地理解:

    a. https://www.youtube.com/watch?v=NRU_KdUSjD4

    b. https://www.youtube.com/watch?v=Dbxzw0cpxBU

© www.soinside.com 2019 - 2024. All rights reserved.