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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Authenticating to CRM API without login screen, NodeJs

(0) ShareShare
ReportReport
Posted on by

I'm able to use postman to fetch data from the CRM api, but it requires a login screen to pop up. Is there a way that I can include my email/password in the headers in order for me to obtain the authorization token?

*This post is locked for comments

I have the same question (0)
  • Eccountable Profile Picture
    10 on at
    RE: Authenticating to CRM API without login screen, NodeJs

    This article looks promising: medium.com/.../dynamics-365-web-api-postman-collection-abfb259f9eae

    If this works, please check this off as the answer

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Authenticating to CRM API without login screen, NodeJs

    I haven't figured out a way to remove the log in screen from Postman, but I can when I make a node application. Using the adal-node library, you can acquire an access token via the acquireTokenWithUsernamePassword function. See this url for the documentation: https://www.npmjs.com/package/adal-node. My code example is below.

    var AuthenticationContext = require('adal-node').AuthenticationContext;
    var clientId = "{{Your clientId here}}"; // Application Id of app registered under AAD.
    var resource = 'https://{{crmUrl}}.crm.dynamics.com/'; // URI that identifies the resource for which the token is valid.
    
    //The url used to login. Common is a general url for microsoft logins
    var authorityHostUrl = 'https://login.windows.net';
    var tenant = `common`; // AAD Tenant name.
    var authorityUrl = authorityHostUrl + '/' + tenant;
    
    var username = '{{Your email here}}';
    var password = '{{Your password here}}';
    
    var context = new AuthenticationContext(authorityUrl, false);
    
    context.acquireTokenWithUsernamePassword(resource, username, password, clientId, function(err, tokenResponse) {
    	if (err) {
    		console.log('well that didn\'t work: ' + err.stack);
    	 } else {
    		console.log(tokenResponse);
    	 }
    });


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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans