Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Re: Cannot get access token.

Here is my solution:


const axios = require('axios');
const adal = require('adal-node');

const getAccessToken = () => {
  const config = {
    username: 'Your Username',
    password: 'Your Password',
    clientId: 'Your Client ID',
    resource: ''

  const authority = ' Tenant'; 
  // Tenant can be found in the Azure Portal.
  // When you access Azure AD, it should show your the name of your tenant.
  // Don't have a link but you can figure out where to get this with some googling.

  let context = new adal.AuthenticationContext(authority, true)
  const callback = (err, accessToken) => {
    if (!err) {
      console.log(accessToken.accessToken); // Returns access token.
      makeApiCall(accessToken.accessToken); --> This is my actual API call.
    } else {

const makeApiCall = (token) => {
  const config = {
    headers: {
      'Authorization': "Bearer " + token,
      'Content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json'

// These options are only used when generating a embedToken.
//{ //accessLevel:"View", //allowSaveAs:"false" //}, const url = ''; axios.get(url, config) .then(response => { let result =; console.log(result); }) .catch(err => { console.log(err); console.log(err.response.status); console.log(err.response.statusText); }) } getAccessToken();

View solution in original post

New Member

Re: Cannot get access token.

i am also facing the similar issue, did you able to figured it out through postman. Please let me know te root cause.

Frequent Visitor

Re: Cannot get access token.

Same issue for me since over half a year now. No solution in sight besides MS C# demo.

Helpful resources

New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors