You can obtain a token for your API Subscription token for testing an API by following these steps:
- Select the POST method from the available operation method dropdown list for your new request in Postman.
- Go to the API Subscriptions details page and then the Native OAuth Application-flow section within Find and Use an API Portal.
- Copy the OAuth token endpoint value. For this example, the value is 'https://login.microsoftonline.com/7d85e51f-c73e-40a8-a5c5-4c3b41de8eb9/oauth2/v2.0/token'. This will be a URL given by the token Business-to-Consumer (B-2-C) provider.
- Paste that URL into the new Request textbox within Postman.
- Select the Body tab for your new request in Postman. You will be presented with all the key and value fields requiring inputs.
Get the OAuth Client ID:
- Go to the API Subscriptions details page and then the Native OAuth Application-flow section within Find and Use an API.
- Copy the OAuth Client ID value.
- Paste it into the Value field for client_id Key field within the Body tab in Postman.
- Check the Value field for grant_type key field is set to 'client_credentials' within the Body tab in Postman.
Get the Primary key value:
- Go to the API Subscriptions detail page and then the Native OAuth Application-flow section withinFind and Use an API Portal.
- Copy the Primary key value.
- Paste it into the Value field for client_secret key field within the Body tab in Postman.
Get the OAuth Scope value:
- Go to the API Subscriptions detail page and then the Native OAuth Application-flow section within Find and Use an API Portal.
- Copy the OAuth Scope value.
- Paste it into the Value field for scope key field within the Body tab in Postman.
- Select the Send button to submit the request to the token provider. You will get a token back as a response. This token can be viewed within the Response Body below in the access_token field value.
Get the Access token value
- Go to the Response Body (in JSON format) for your submitted request in Postman.
- Find the field access_token.
- Copy this access_token value. It will look something like 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'
- Go back to your request in Postman.
- Select the Authorisation tab for your new request in Postman.
- Go to the Type dropdown option, select Bearer token for type.
- Paste the access_token value you copied to the Token textbox presented to you in Postman.
- Select the Send button again, to submit the request with the Bearer token now added. This will return a response for the API that can be viewed within the Response body in Postman. The response will contain various fields and values including headers, any query parameters, response message and timestamp in JSON format within Postman. You can also download the JSON response file.