You can use Postman to obtain a token by using a service principal through the client credential flow.
To use Postman with service principal you need to first create a service principal with certain configuration. Here is a guide on how to create a service principal for Workbench.
- Open Postman. You can download Postman here.
- We need to make a Post request to AAD's token service
- Set the method to
POST
- Set the URL to
https://login.microsoftonline.com/<tenant_name>/oauth2/token
- Navigate to the
body
tab - Set the body type to
x-www-form-urlencoded
- Add the following parameters:
resource
: Workbench's AppIdclient_id
: service principal AppIdclient_secret
: service principal app key (secret)grant_type
:client_credentials
- Click on
Send
to make the call
- If the call is successful you will receive a JSON containing the
access_token
(bearer token). Copy this token.
-
In this example we are going to make a
GET
call to/api/v1/users
to get all the users. Set the operation toGET
and the url to<workbench_url>/api/v1/users
-
Navigate to the
Authorization
tab- Select
OAuth 2.0
from the dropdown menu - Paste your
access_token
in the text box
- Select
-
Click on send and you should get a list of users
Note: This token will expire in an hour, you need to make another post call to get a new token.
Some API calls need Admin privileges, make sure when you're creating your service principal for Workbench that the service principal has adequate permissions for the operation that you are trying to perform.