web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Connecting to Dynamics 365 CRM via Console App in C#

(0) ShareShare
ReportReport
Posted on by 37

Im trying to connect to dynamics 365 via console application, using CrmServiceClient, need to input a connection string;

one of the stuff there is "RedirectUri". where do i get that from ?

Here's my Code:

static void ConnectToCrm()
{
    string connectionString = @"Authtype-OAuth;
    Username=username;
    Password=password;
    Url=https://crmurl.crm4.dynamics.com/;
    AppId= ;
    RedirectUri= ;
    LoginPrompt=never";

    crmService = new CrmServiceClient(connectionString);
    Console.WriteLine($"is ready: {crmService?.IsReady}");
    Console.Read();
}

I have the same question (0)
  • Suggested answer
    Kenneth Ariel Chaves Herrera Profile Picture
    on at

    Hi,

    Here you can find how to use the RedirectUri:

    Redirect URI (reply URL) restrictions - Microsoft identity platform | Microsoft Docs

    If this was helpful, please check it as verified to help others finding useful information.

    Welcome to this amazing community.

  • Verified answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    You can refer to my sample code, You will need to change the username, password and organization: 

    gist.github.com/.../77f718d9a5802d4d087722d9e6a61d0a

    Docs: 

    The AppId and RedirectUri provided above are examples of working application registration values. These values work everywhere our online services are deployed. However, they are provided here as examples and you are encouraged to create your own application registration in Azure Active Directory (Azure AD) for applications running in your tenant. Use your Username, Password, and Dataverse environment URL values in the connection string along with the RedirectUri and AppId you obtain from your Azure app registration.

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/authenticate-office365-deprecation#what-should-i-do-to-fix-my-application-code-if-affected

  • MicroDynamicalCRM Profile Picture
    37 on at

    at azure app overview i see

    Aplication (client) ID, Object ID, Directory (tenant) ID

    at Redirect URIS field there is no uri id...

    i didnt understand from where do i get this RedirectUri

    could you try to give a little more detailed direction where to look ?

  • MicroDynamicalCRM Profile Picture
    37 on at

    ok after a few minutes of looking around i found out that the Redirect Uri is actually a connection path opening given for impersonating another admin user which i assume its the SYSTEM user that's built in... took me some time to figure that out - correct me kindly if i missed something here

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 51

#2
Martin Dráb Profile Picture

Martin Dráb 39 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 26 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans