Run the code by pressing f5. You will be prompted to enter your user credentials. After entering the credentials the server returns an Authentication Token.

The AccessToken and the AccessTokenType (“Bearer”) is what we need to include into every Authorization header of http request.

Next into every requests we make to the CRM Web API we need to pass this authentication token. Below is a Sample Code which demonstrates use of CRM Web API for Create, Retrieve, Update and Delete Operations.

Microsoft has also provided helper code to authenticate using credentials stored in the .config file. In my next article I will demonstrate how to use this helper code and authenticate users directly using the credentials stored in the .config file.