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 17.
examples/oauth2/api
.authorization_server
token_validator
Fist, we need a new request. You can either use the default request that appeared initially or create a new one.
Enter the URL localhost:2000
and click 'Send'.
You'll notice that the server returns a status code 400 Bad Request
. This occurs due to the absence of a
valid Token.
Now go to localhost:9000 and click on Authorization Server
Here, you can see that there was one request made with an invalid access token. If you repeat the request, the count will increase accordingly.
Authorization
OAuth2
as a type.Configure New Token
section.
Get New Access Token
Use Token
. This
action selects the token to be used for our request.
Now go back to the Admin Console
You can now see that one Access Token has been created.
Once you pressed Use Token
, the Access Token is set and will be used for the following requests.
Now Click on Headers
.
The Authorization
Header is set to the requested Token. Now repeat the request to localhost:2000 using this Header. The request will return a status code 200 Ok
along with the following body:
{
"success": true
}
When you return to the Admin Console again, you'll notice there is now one request with a valid access token.