Wednesday 7 February 2018

Creating a Simple JavaScript application to use Dynamics CRM Online Web API

This post is in extension to the msdn blog that gives a walk through on Registering and configuring simple single page application with adal.js.
This referenced blog has been written with reference to old Azure portal ( manage.windowsazure.com ) and there has been a change on the Azure side ( portal.azure.com ). This post explains it with respect to the new azure portal.
Prerequisites
  • Microsoft Dynamics CRM Online 2016 Update
  • You must have a Microsoft Dynamics 365 (online) system user account with administrator role for the Microsoft Office 365.
  • A Microsoft Azure subscription for application registration. A trial account will also work.
  • Microsoft Visual Studio 2015
Sample Code

The sample code is available in the original blog as well as here ( with minor tweaks). Note that the clientid to be passed in the code will be the Application ID that you would get in the Registration processs below.
Register the application
1.  Sign in to Azure - https://ms.portal.azure.com , You must use an account in the same Office 365 subscription (tenant) as you intend to register the app with. You can also access the Microsoft Azure portal through the Office 365 admin center by expanding the ADMIN item in the left navigation pane and selecting Azure AD.
 
2. Click on New Application registration , Provide any Name , Choose the Application Type as Web App/Web API and Sign-on URL that later translates to Home Page Url also called as Redirect Url is the URL which the user should be redirected to after they sign in and this field can be changed at later point of time.
3. Once created, Click on Manifest and change the property from false to true "oauth2AllowImplicitFlow": true and Save the Manifest file , Else it would throw the error as below
"adal error occurred: aadsts70005: response_type 'token' is not enabled for the application"
4. Add permissions to the Dynamics CRM Online Web API as below, Else it would throw the below error.
"ADAL error occurred: AADSTS65001: The user or administrator has not consented to use the application with ID 'ce2b1c70-06e3-430f-8672-41ef6d03da2d' named 'CRMJavascript'. Send an interactive authorization request for this user and resource. Trace ID: 7b81cedf-dec2-4e68-a91f-ecdb192a0800 Correlation ID: a559a661-4909-4c2f-a629-5edef06e3df8 Timestamp: 2018-02-07 02:41:21Z"


Below screen gives is the information on Grant Permissions screen.

13 comments:

  1. HI I am getting following error .....Please help what exactly grant permission need to give....


    ADAL error occurred: AADSTS65001: The user or administrator has not consented to use the application with ID '4e980f8c-0369-41a6-9e73-c0001a377790' named 'WebAPICall'. Send an interactive authorization request for this user and resource. Trace ID: 88043375-8abc-4d3f-9656-246258e36900 Correlation ID: 438549d3-0b6d-4e6e-89f4-cbc755ff2672 Timestamp: 2018-08-18 15:15:58Z

    ReplyDelete
    Replies
    1. Sorry for delay in response.. I have updated the screenshot now.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I found Hubwit as a transparent s ite, a social hub which is a conglomerate of Buyers and Sellers who are ready to offer online digital consultancy at decent cost. Roblox APK MOD Download Free

    ReplyDelete
  4. If you don"t mind proceed with this extraordinary work and I anticipate a greater amount of your magnificent blog entries TubeMate PC Download Latest Version Plus Installation Guide

    ReplyDelete
  5. I am constantly browsing online for tips that can assist me. Thanks!
    big data solution providers

    ReplyDelete
  6. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work 金融作业代写

    ReplyDelete
  7. Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!
    defer parsing of js wordpress

    ReplyDelete
  8. In our years of working in the SaaS space, we can't tell you how many meetings we've attended where an executive expressed those frustrations. Even in organizations where best crm comparison chart adoption is mandated, teams and individuals will still riotously resist changes in systems, processes, reporting, you name it.

    ReplyDelete
  9. I gained new knowledge from well written content of this blog. It is showing some different kind of strategy to keep work better and improve with every new assignment. Gracefully written blogHow to get rid of Discord Javascript Error | newscutzy.com

    ReplyDelete
  10. You re in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject! ñustomer relationship management for free

    ReplyDelete
  11. Nature always helps a writer to learn from its elements. Nature always try to teach new lessons and a writer transform its experience into words. He can transform even silence into words. This blog taught me a lesson.Discord Javascript Error

    ReplyDelete
  12. ▷ Casino site ⋆ Join Now & Earn Money With
    Casino site ❤ No deposit bonuses ☆ Huge jackpot slots and jackpots ✔️ Play for free, cash, BTC, ETH or BCH here and now!⭐ No deposit luckyclub.live bonus codes Needed

    ReplyDelete