AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 372 forks source link

ADAL JS integration on dynamic crm failed to get power bi rest api, getting 403 #841

Closed ShahriatHossain closed 5 years ago

ShahriatHossain commented 5 years ago

I have integrated adal.js library in my dynamic crm custom solution. I can get token easily but when trying to call power bi rest api using the following code below getting 403 unauthorized status:

var headers = new Headers();
                    var bearer = "Bearer " + token;
                    headers.append("Authorization", bearer);
                    var options = {
                        method: "GET",
                        headers: headers
                    };
                    var graphEndpoint = "https://api.powerbi.com/v1.0/myorg/reports";

                    fetch(graphEndpoint, options)
                        .then(function (response) {
                            //do something with response
                            console.log(response);
                        });

Do I need to use username and password and how to use it using adal.js, any suggestion?

Thanks in advanced.

ShahriatHossain commented 5 years ago

I have resolved the issue.