How to migrate from Passport authentication type to OAuth 2.0

Forum Post: Change the Filter On option on Opportunity Associated View for Account form


Got this error while attempting to connect to Dynamics CRM 365 OrganizationService:

Error Message: 

Message=An error occurred when processing the security tokens in the message:You are using Ws-Trust authentication which has been deprecated and no longer supported in your environment. Please use OAuth2.0 authentication.
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Create(Entity entity)
at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClassd.<Create>b__c(IOrganizationService s)

Used this “Ws-Trust authentication which has been deprecated and no longer supported in your environment. Please use OAuth2.0 authentication” to search around and the answer was to change the connection string to something like this: 

connectionstring = “AuthType=OAuth;[email protected]; Password=passcode;;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Auto”

But I tried that (substituted with my own secrets) but it still gave me same error.      

Here are the codes to connect:

using Microsoft.Xrm.Client;


private readonly CrmConnection _crmServiceConnection;

in the constructor, set:

    _crmServiceConnection  = CrmConnection.Parse(dynamicsConfigurationProvider.ConnectionString);

And the connection is used in 

using (var service = new OrganizationService(_crmServiceConnection))
var accountId = service.Create(dynamicsAccount);


I looked up the OrganizationService meta data and it seemed old:

#region Assembly Microsoft.Xrm.Client, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// C:\Users\.userid\.nuget\packages\microsoft.crmsdk.extensions\\lib\net45\Microsoft.Xrm.Client.dll
// Decompiled with ICSharpCode.Decompiler

Thanks in advance for your help!!

Source link

Leave a reply

Please enter your comment!
Please enter your name here