In this blog post, we are going to use Postman to validate the configuration of the Authorisation Server (Microsoft Azure Active Directory) from Part 2 of this blog series.

Prerequisites

Postman is a tool that allows developers to quickly create HTTP messages to test web services. Postman can be download from https://www.getpostman.com/.

Testing Microsoft Dynamics CRM Web API with Postman

 

Although not required until part 4 of this blog series, the source code for the demo ASP.NET MVC application can be found on Codeplex at https://crmdynamicsoauthwebapiexample.codeplex.com/.

Get New Access Token

This section provides instructions to generate an authentication token in Postman. To generate the token, the application ID (client ID) and client secret created in Part 2 of this blog series is required.

  1. Open Postman.
  2. Open a new Postman Tab.
  3. Set the URL to the Accounts Microsoft Dynamics CRM Web API Endpoint. My URL <WebAPI Endpoint>/Accounts.

For example: https://11Nov2016.api.crm6.dynamics.com/api/data/v8.1/Accounts.

This can be retrieved from the Microsoft Dynamics CRM in the Settings >Customizations > Developer Resources Section.

  1. Select the Authorization Tab.
  2. Set the Authorization Type to OAuth 2.0.
  3. Click on Get New Access Token Button.

oauth-2-0

  1. Set The following values in the Get New Access Token dialog
    1. Token Name: Token
    2. Auth URL: https://login.windows.net/common/oauth2/authorize?resource=<URL Encoded Url to Web API Endpoint>.

My econded Web API endpoint looks like this: https%3A%2F%2F11Nov201.api.crm6.dynamics.com%2f. You could potentially replace the 11Nov2016 with your own domain.

Example of complete Auth Url: https://login.windows.net/common/oauth2/authorize?resource=https%3A%2F%2F11 %2f

  1. Access Token URL: https://login.microsoftonline.com/common/oauth2/token
  2. Client Id: Application Id (Client Id) that was created in Part 2 of this blog series. Eg. 6a3622c4-8ba7-47a7-93e3-ebc0e1aa936f
  3. Client Secret: Client Secret that was created in Part 2 of this blog series. Eg. cytHrW+vFPyh+osZvvKZzlPds/PUKbEMIHcddHb2XRI=
  4. Grant Type: Authorization Code
  1. Click the Request Token button.

get-new-access-token

  1. A Microsoft Dynamics CRM login screen is displayed. Log in using the username and password created in Part 2 of this blog series when creating a trial of Microsoft Dynamics CRM.

login

  1. Select the token that will now be displayed in the list of existing tokens.
  2. Click on the use token button; the Authorization header will now exist under the headers tab.

use-token-button

  1. Click on the headers tab; notice there is already an authorization header.
  2. Add a new content type of application/json header.

add-new-content-type

  1. Click on the send button.

click-on-send-button

  1. A list of accounts will be returned. Note your Dynamics CRM instance may have zero accounts and you may get an empty list of accounts returned to Postman.

Summary

This blog post demonstrates how to use Postman to perform an OData query against the Dynamics CRM Web API endpoint, allowing developers to quickly validate third-party applications are configured with Dynamics CRM permissions in Azure Active Directory correctly.