WaelHamze / dyn365-ce-vsts-tasks

VSTS Extension for Dynamics 365 Customer Engagement
https://marketplace.visualstudio.com/items?itemName=WaelHamze.xrm-ci-framework-build-tasks
GNU General Public License v3.0
115 stars 54 forks source link

AuthType=OAuth Connection String question #262

Open foodware365 opened 2 years ago

foodware365 commented 2 years ago

Hi,

Until now we use the tooling to import data into existing environments automated in Azure DevOps pipelines, the application user is created in this environment with enough permissions to import data, Connection String used in this scenario: AuthType=ClientSecret;url="$(CDSEnvironmentUrl)";ClientId="$(CDSClientId)";ClientSecret="$(CDSClientSecret)" With this setup we are successful to connect and import the data.

To the above scenario we now also added the task to create a new environment automated in Azure DevOps pipelines. In this new environment we also want to import the data but the problem we face is that in this new environment the application user is not setup. In the new environment the admin user is added by default so we tried to use this admin user to import the data but we aren't able to setup the connection reference, current connection string: AuthType=OAuth;url="$(EnvironmentUrl)";UserName="$(CDSAdminUser)";Password="$(CDSAdminPassword)";AppId={appid};RedirectUri="api://xxxxxxx";TokenCacheStorePath="$(System.DefaultWorkingDirectory)/MyTokenCache";LoginPrompt=Never

The pipeline logs show: [error]Couldn't connect to CRM instance after 3 attempts: ERROR REQUESTING Token FROM THE Authentication context - General ADAL Error Unable to connect to CRM: user_interaction_required: One of two conditions was encountered: 1. The PromptBehavior.Never flag was passed, but the constraint could not be honored, because user interaction was required. 2. An error occurred during a silent web authentication that prevented the http authentication flow from completing in a short enough time frame

Can you help us, maybe we are not at the right track or have to automate also the creation of the application user in the new environment, any help or information is much appreciated.