Forum Discussion
Can not get Access Token to use with PowerBI API
Hello,
I am having trouble with trying to generate an access token for PowerBI JavaScript API in an app-owns-data scenario.
Following the example, I got the whole process working (with a new, custom tenant as said by the instructions).
Now, I need to move it onto the real tenant that it is being implemented on. However, when I try to get a token like before, it spits out an error saying that my username or password is incorrect, when I know for sure that it is not.
Here's an example of the code I'm using to query for one:
var settings = {
"url": "https://login.microsoftonline.com/common/oauth2/token",
"method": "POST",
"headers": { "Content-Type": "application/x-www-form-urlencoded" }
}
settings['data'] = "resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&client_id=(azurenativeapiapplicationid)&grant_type=password&[email protected]&password=notrealpassword&scope=openid";
$.ajax(settings).done(function(result){console.log(result)});