Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to get entity record from external HTML form using Azure Active Directory?

Posted on by Microsoft Employee

Hi,

I want to get data from CRM account from external HTML page and JS by Azure Active Directory.

1. Can you please guide me to connect Azure with Dynamics CRM?

2. How to get Client ID from Azure??

3. How to get Tenant (The name of the Azure AD organization) from Azure?

Here I am calling external HTML page. 

var organizationURI = "***"; //The URL to connect to CRM (online)
var tenant = "***.onmicrosoft.com"; //The name of the Azure AD organization you use
var clientId = "***"; //The ClientId you got when you registered the application
var pageUrl = "***"; //The URL of this page in your development environment when debugging.

var endpoints = {
orgUri: organizationURI
};

window.config = {
tenant: tenant,
clientId: clientId,
postLogoutRedirectUri: pageUrl,
endpoints: endpoints,
cacheLocation: 'localStorage', // enable this for IE, as sessionStorage does not work for localhost.
};

function authenticate() {
//OAuth context
authContext = new AuthenticationContext(config);

// Check For & Handle Redirect From AAD After Login
var isCallback = authContext.isCallback(window.location.hash);
if (isCallback) {
authContext.handleWindowCallback();
}
var loginError = authContext.getLoginError();

if (isCallback && !loginError) {
window.location = authContext._getItem(authContext.CONSTANTS.STORAGE.LOGIN_REQUEST);
}
else {
errorMessage.textContent = loginError;
}
user = authContext.getCachedUser();

}

function login() {

         authContext.login();

}

*This post is locked for comments

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: How to get entity record from external HTML form using Azure Active Directory?

    Hi Chhaya,

    var tenant = "[xxx.onmicrosoft.com]", so in you case if org name is 'org' and your region is 'US' then it will be org.crm.dynamics.com.

    Just copy this from your crm url.

    var clientId = "[client id]"; //The ClientId you got when you registered the application

    In the new portal, the ApplicationID is the same as Client ID. However the URL i mentioned should be following using classic azure portal i.e. https://manage.windowsazure.com

    Let me know if you need further clarification.

    Thanks,

    Prateek

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get entity record from external HTML form using Azure Active Directory?

    Thanks Prateek!

    Actually I'm confuse in "Tenant" and "ClientId". I don't know what should I pass in "tenant" and "ClientId"

    Can you please guide me for above 2 parameters?

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: How to get entity record from external HTML form using Azure Active Directory?

    Please follow this walkthrough:

    msdn.microsoft.com/.../mt595797.aspx

    Prateek

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans