Using Postman to request and authenticate with OAuth2 tokens
This step-by-step tutorial explains how to request OAuth2 tokens using Postman, and how to use the tokens to authenticate HTTP requests.
Before we start sending requests, we first need to set up our environment.
Make sure you have downloaded the latest release
.zip of the Membrane API Gateway, we use Membrane as our OAuth2 token server.
To run Membrane you will require a JDK of at least version 11.
- Extract the Membrane archive and navigate to
- Start the Windows or *nix shell scripts in
Note: Only start one
service-proxy.* in each directory.
- If Postman is not already installed, download it from the official Postman downloads page.
After Postman is installed, you can run the application.
You have the choice of logging in, or using Postman in Lite mode.
Requesting the OAuth2 Token
- Use the default request that appeared on first start or create a new one.
- Click on
Authorization and scroll to the
Configure New Token section.
In our instance we will be authenticating with the token server using password authentication. Select
Password Credentials in the
Grant Type dropdown and proceed with the entry of your or the examples data.
In this example we use
Client ID and
Access Token URL is
Username: John and
Password: password to authenticate.
- Enter any name for the Token and press
Get New Access Token.
The token server will be contacted and if the information was entered correctly, a success modal should appear.
- Press proceed (or wait for the modal to close), on the next screen press
Use Token, this will select token to be used for our request.
Using the OAuth2 Token in a Request
- Make sure the right token is selected. Then enter the target url and send the request.
The response window at the bottom should show a JSON document denoting that the token validation was a success.
In this example we use the target URL
http://localhost:2000, this is simply a token validator running in Membrane.