Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

(0) ShareShare
ReportReport
Posted on by 422

Hi,

I want to get organization service with office365 type, that is AuthType of connecctionString is OAuth. But the connectionString must have RedirectUri field, I don't know how to get the RedirectUri. Does anyone know?

Thanks,

Dejun

  • Stone Huang Profile Picture
    Stone Huang 422 on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Thank you so much. I will try it.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,961 Moderator on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Hi,

    Yes that is required.

    If found helpful, Please mark my answer verified.

  • Stone Huang Profile Picture
    Stone Huang 422 on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Do you know that I still need to request a API permission for Dynamics CRM on the Azure?

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,961 Moderator on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Hi,

    I now have an Azure AD account, I also register a app on the Azure, and after that? Request a API permissions for Dynamics CRM? or add this account into our CRM system directly and give it administrator rights?

    Follow Step to create Application User in CRM

    1. Copy Application ID from App registration page from azure portal

    2. Navigate to settings->Security->User->Change view to select Applications User

    3. Create New+User->Change form to select APplication User from User

    4. Paste Application ID which you have copied to Application ID field

    5. Provide User name and first name and last name.

    6. click on save. verify two other field related to Azure automatically populated

    7. Click on Manage user ribbon button and assign security role

    And you are good to go.

    If found helpful, Please mark my answer verified.

  • Stone Huang Profile Picture
    Stone Huang 422 on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Thank you so much. Your link let me understand redirect uri very well.

  • Stone Huang Profile Picture
    Stone Huang 422 on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Hi Bipin,

    You're a real expert. A lot of questions that I didn't understand before, but now I understand  through your explanation.

    I also want to ask you some extensioned question. I'm not sure if you also know. That is, if I have an Azure AD account, I want to set it as an administrator of our CRM system and use it to get services, what do I need to do?

    I now have an Azure AD account, I also register a app on the Azure, and after that? Request a API permissions for Dynamics CRM? or add this account into our CRM system directly and give it administrator rights?

    Because the way we used now to get the service is very different from the way this connection string is used. So this type of using the connection string to get service is very refresh for me.

  • Suggested answer
    Nishant Rana Profile Picture
    Nishant Rana 11,320 Microsoft Employee on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    This might be of some help

    nishantrana.me/.../

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,961 Moderator on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Hi,

    If you don't want to show prompt for login then use below property and set valut to Never.

    LoginPrompt Specifies whether the user is prompted for credentials if the credentials are not supplied. Valid values are:

    - Always: Always prompts the user to specify credentials.

    - Auto: Allows the user to select in the login control interface whether to display the prompt or not.

    - Never: Does not prompt the user to specify credentials. If using a connection method does not have a user interface, you should use this value.

    This parameter is applicable only when the authentication type is specified as OAuth.

    I have created console application to use oauth authentication. See below github repository and add your CRM URL, Username and password and playaround with it.

    github.com/.../App.config

    If found helpful, Please mark my answer verified.

  • Stone Huang Profile Picture
    Stone Huang 422 on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Thank you very much for your patient answer. Although I still have questions, your answer has solved a lot of my confusion.

    I know AuthType have OAuth and Office365, but I really haven't heard of ClientSecret as a type of certification. I'm not sure if you know that Microsoft will soon no longer support WS-Trust authentication, and my code uses this authentication method, so I want to change the authentication method from WS-Trust to OAuth, but if it is changed to OAuth, then redirect uri is necessary, that's why I asked about redirect uri.

    I don't know whether ClientSecret, like WS-Trust, is an outdated authentication method that will be deprecated.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,961 Moderator on at
    RE: What is RedirectUri in the connectionString of CrmServiceClient, How do I get this RedirectUri?

    Hi,

    Before I answer your question I want to understand where do you want to use this code to get organization service?

    Are you writting any Console Application/Azure web job?

    If yes - You can use clientcrendentials auth type which does not require prompt and it is non-interactive.

    <add name="MyCDSServer"

     connectionString="

     AuthType=ClientSecret;

     url=contosotest.crm.dynamics.com;

     ClientId={AppId};

     ClientSecret={ClientSecret}

     />

    Client  secret can be generated in App registration, Client ID is nothing but Application ID.

    Do you have any standalone web application where you want user to enter their credentials then you should use Oauth which will prompt login window to enter user password.

    <add name="MyCDSServer"

    connectionString="

     AuthType=OAuth;

     Username=jsmith@contoso.onmicrosoft.com;

     Integrated Security=true;

     Url=contosotest.crm.dynamics.com;

     AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;

     RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;

     TokenCacheStorePath=c:\MyTokenCache;

     LoginPrompt=Auto"/>  

    Replace redirect URI with your URI in app registration which I have highlighted in my images.

    Now see my answer to your questions.

    1. Does the URI highlighted in the image have to be consistent with the RedirectUri in the connection string in the code? why? - Yes redirect URI should be same as App Registration and Application ID should also be replaced with app registartion application ID.

    2. In the image, it explains the role of URI, my question is that I use this URI just to concatenate the connection string to get the organization service. If it succeeds, it will return a service instance(e.g. IOrganization...). I don't need it to go to URI address. That's why I've been confused about this Redirect URI. - You are right, you don't have to go to this URI.

    If found helpful, Please mark my answer verified.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans