Multi-tenant server-to-server authentication - User consent issue












1















I have followed this walkthrough to create a multi-tenant web application that can connect to Dynamics 365 CE Online. Walkthrough: Multi-tenant server-to-server authentication.



When I ran the app for the first time and tried to sign in to the Dynamics CRM, it asked me to provide a consent that I accepted. And then it returned the below error:




Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException HResult=0x80131500 Message=AADSTS65001: The user or administrator
has not consented to use the application
with ID
'XXX' named 'MvcCrmStsWalkthrough'.
Send an interactive authorization request for this user and resource.




For subsequent tries, it didn't ask for consent. However, kept returning the aforementioned error.



What I have used for this POC




  • Dynamics CRM Online trial

  • Azure Active Directory service that was included by default with the CRM
    trial and was enough to perform application registration on Azure AD

  • Visual Studio 2017 community edition


What I have tried so far




  • In Azure AD I already have granted permission using the 'Grant Permission' button on the registered app Settings > Required Permissions (Seems accepting user consent through my custom app does the same)

  • Setting oauth2AllowImplicitFlow to true in the Azure AD app manifest

  • I verified that the O365 account that I am using to log in through the app has Global Administrator directory role in the AD


Sample code



Exactly the same as mentioned in the walkthrough










share|improve this question





























    1















    I have followed this walkthrough to create a multi-tenant web application that can connect to Dynamics 365 CE Online. Walkthrough: Multi-tenant server-to-server authentication.



    When I ran the app for the first time and tried to sign in to the Dynamics CRM, it asked me to provide a consent that I accepted. And then it returned the below error:




    Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException HResult=0x80131500 Message=AADSTS65001: The user or administrator
    has not consented to use the application
    with ID
    'XXX' named 'MvcCrmStsWalkthrough'.
    Send an interactive authorization request for this user and resource.




    For subsequent tries, it didn't ask for consent. However, kept returning the aforementioned error.



    What I have used for this POC




    • Dynamics CRM Online trial

    • Azure Active Directory service that was included by default with the CRM
      trial and was enough to perform application registration on Azure AD

    • Visual Studio 2017 community edition


    What I have tried so far




    • In Azure AD I already have granted permission using the 'Grant Permission' button on the registered app Settings > Required Permissions (Seems accepting user consent through my custom app does the same)

    • Setting oauth2AllowImplicitFlow to true in the Azure AD app manifest

    • I verified that the O365 account that I am using to log in through the app has Global Administrator directory role in the AD


    Sample code



    Exactly the same as mentioned in the walkthrough










    share|improve this question



























      1












      1








      1


      0






      I have followed this walkthrough to create a multi-tenant web application that can connect to Dynamics 365 CE Online. Walkthrough: Multi-tenant server-to-server authentication.



      When I ran the app for the first time and tried to sign in to the Dynamics CRM, it asked me to provide a consent that I accepted. And then it returned the below error:




      Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException HResult=0x80131500 Message=AADSTS65001: The user or administrator
      has not consented to use the application
      with ID
      'XXX' named 'MvcCrmStsWalkthrough'.
      Send an interactive authorization request for this user and resource.




      For subsequent tries, it didn't ask for consent. However, kept returning the aforementioned error.



      What I have used for this POC




      • Dynamics CRM Online trial

      • Azure Active Directory service that was included by default with the CRM
        trial and was enough to perform application registration on Azure AD

      • Visual Studio 2017 community edition


      What I have tried so far




      • In Azure AD I already have granted permission using the 'Grant Permission' button on the registered app Settings > Required Permissions (Seems accepting user consent through my custom app does the same)

      • Setting oauth2AllowImplicitFlow to true in the Azure AD app manifest

      • I verified that the O365 account that I am using to log in through the app has Global Administrator directory role in the AD


      Sample code



      Exactly the same as mentioned in the walkthrough










      share|improve this question
















      I have followed this walkthrough to create a multi-tenant web application that can connect to Dynamics 365 CE Online. Walkthrough: Multi-tenant server-to-server authentication.



      When I ran the app for the first time and tried to sign in to the Dynamics CRM, it asked me to provide a consent that I accepted. And then it returned the below error:




      Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException HResult=0x80131500 Message=AADSTS65001: The user or administrator
      has not consented to use the application
      with ID
      'XXX' named 'MvcCrmStsWalkthrough'.
      Send an interactive authorization request for this user and resource.




      For subsequent tries, it didn't ask for consent. However, kept returning the aforementioned error.



      What I have used for this POC




      • Dynamics CRM Online trial

      • Azure Active Directory service that was included by default with the CRM
        trial and was enough to perform application registration on Azure AD

      • Visual Studio 2017 community edition


      What I have tried so far




      • In Azure AD I already have granted permission using the 'Grant Permission' button on the registered app Settings > Required Permissions (Seems accepting user consent through my custom app does the same)

      • Setting oauth2AllowImplicitFlow to true in the Azure AD app manifest

      • I verified that the O365 account that I am using to log in through the app has Global Administrator directory role in the AD


      Sample code



      Exactly the same as mentioned in the walkthrough







      azure dynamics-crm azure-active-directory dynamics-crm-online dynamics-365






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 18:22







      Khadim Ali

















      asked Nov 20 '18 at 18:17









      Khadim AliKhadim Ali

      1,59821949




      1,59821949
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399142%2fmulti-tenant-server-to-server-authentication-user-consent-issue%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399142%2fmulti-tenant-server-to-server-authentication-user-consent-issue%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini