春季:如何从邮递员那里获取Oauth2令牌?

时间:2019-09-22 12:48:41

标签: java spring oauth-2.0 spring-oauth2

我已按照此spring-security-oauth-example创建了Oauth2服务器。如何从邮递员那里获得Oauth2令牌?

这是资源服务器的代码,这是 AuthorizationServerConfig.

我想了解如何从邮递员那里获取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

1 个答案:

答案 0 :(得分:1)

在邮递员中设置OAuth 2.0令牌的步骤。

  1. 打开邮递员。

  2. 创建一个新请求。点击authorization标签。下面的屏幕截图:

enter image description here

  1. 选择身份验证的Type作为OAuth 2.0。下面的屏幕截图:

    enter image description here

  2. 现在,单击Get New Access Token。它将弹出以显示以下内容:

enter image description here

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

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

  1. The OAuth 2.0 Authorization Framework-这将使您了解什么是OAuth 2.0自动化框架?

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

enter image description here

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

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

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

希望这对您有所帮助。

谢谢。 :)