Pale Blue Dot
Pale Blue Dot

Reputation: 67

Spring : How to get Oauth2 token from Postman?

I have created Oauth2 server following to this spring-security-oauth-example. How can I get the Oauth2 token from Postman ?

This is the code for Resource Server and this is the code for AuthorizationServerConfig.

I want to understand how can I get the Oauth2 token for clientid = "ClientId" from Postman ? And what these below code signify:

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 has

 server.port=8081 
 server.context-path=/auth security.basic.enable=false

Upvotes: 1

Views: 9646

Answers (1)

Anish B.
Anish B.

Reputation: 16469

The steps to set up the OAuth 2.0 token in Postman.

  1. Open Postman.

  2. Create a new request. Click on "authorization" tab. Screenshot below :

enter image description here

  1. Select Type of authentication as OAuth 2.0. Screenshot below :

enter image description here

  1. Now, click on the "Get New Access Token". It will pop up to show this below :

enter image description here

  1. Enter the desired details like Client ID, Client Secret, CallBack URL, Auth URL, Access Token URL etc.

So, I'm adding some helpful resources for you to understand the OAuth 2.0 Type.

  1. The OAuth 2.0 Authorization Framework - This will give an idea what is OAuth 2.0 Authorization Framework?

A screenshot from the above link : How the Oauth 2.0 Authorization Framework looks like.

enter image description here

  1. Some video lectures to understand it visually :

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

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

Upvotes: 4

Related Questions