Question
"I need to write a small console app that can authenticate to an online CRM instance with multi-factor authentication turned on. Can anyone point me in the right direction on how to accomplish this?"
Here is the code😉😉
using
Microsoft.Xrm.Tooling.Connector;
var
connectionString =
@"
AuthType=OAuth;
Username=<username>;
Url=https://<yourorg>.crm.dynamics.com;
AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;
RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;
TokenCacheStorePath=c:\MyTokenCache;
LoginPrompt=Auto"
;
var
client =
new
CrmServiceClient(connectionString);
if
(client.IsReady)
{
Console.WriteLine(
"OK"
);
}
else
{
Console.WriteLine(client.LastCrmError);
[Don’t forget to] Add Nuget package Microsoft.CrmSdk.XrmTooling.CoreAssembly
No comments:
Post a Comment