in Education by
I'm trying to use the Power BI REST API, using an access token acquired with the "client credentials" method, but I keep getting 403 Forbidden on my requests. My code follows the pattern demonstrated in this AzureAD sample. In fact, to isolate this problem, I'm running that sample code (with my own values in the parameters.json, of course): { expiresIn: 3599, tokenType: 'Bearer', expiresOn: Tue Sep 01 2015 16:56:07 GMT-0500 (CDT), resource: '00000002-0000-0000-c000-000000000000', accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiIwMDAwMDAwMi0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8xM2QxNzIwNC0wZGU2LTQ1NzQtOTgzYS05NjFhYjk0M2M3Y2UvIiwiaWF0IjoxNDQxMTQwNjcwLCJuYmYiOjE0NDExNDA2NzAsImV4cCI6MTQ0MTE0NDU3MCwidmVyIjoiMS4wIiwidGlkIjoiMTNkMTcyMDQtMGRlNi00NTc0LTk4M2EtOTYxYWI5NDNjN2NlIiwib2lkIjoiYzM1ZWQyYTktYTYzZS00YzAwLThmYmYtY2FlYjlmZjYwMjYwIiwic3ViIjoiYzM1ZWQyYTktYTYzZS00YzAwLThmYmYtY2FlYjlmZjYwMjYwIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvMTNkMTcyMDQtMGRlNi00NTc0LTk4M2EtOTYxYWI5NDNjN2NlLyIsImFwcGlkIjoiNDQ2Y2Y5OTItMDQzYS00YjgxLWJhYzQtY2RlZWYyNGFhNzFjIiwiYXBwaWRhY3IiOiIxIn0.YTGJfdW1wP09bDHwwsv3FPAmEpmQdc_kifvgY-1KjhkZWANfYtd050wfeZdNgMUeSPZyFdWnoBjnJ4xrlDtnsADwV1Grr6TXYcymPLofbY-xy0cjyvzxTmM11DJ9XN8A4tkgvK0jtR-YyIjPw5EKJSKyeEbD9U3mWsE_gu7IzKzXl8e-dfVAqRYS6WHZy6_0FaNmppPDls5s_QIPOHofFSiWVISw41Mz0fQnP2QEGyceOCvKYJtrUOCDwfVuwFS-gSLmYvEGOJfmIjftP3srda0JPirVzBeU0IFJJ1KW81kE5cfKw1KkBB04VVetRUs_7HqloYaKKiTybauhXAodRQ', isMRRT: true, _clientId: '[snip]', _authority: 'https://login.windows.net/[snip]' } When I use that access token in a curl request, as follows, I get 403: curl -vv -X GET https://api.powerbi.com/v1.0/myorg/datasets -H"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiIwMDAwMDAwMi0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8xM2QxNzIwNC0wZGU2LTQ1NzQtOTgzYS05NjFhYjk0M2M3Y2UvIiwiaWF0IjoxNDQxMTQwNjcwLCJuYmYiOjE0NDExNDA2NzAsImV4cCI6MTQ0MTE0NDU3MCwidmVyIjoiMS4wIiwidGlkIjoiMTNkMTcyMDQtMGRlNi00NTc0LTk4M2EtOTYxYWI5NDNjN2NlIiwib2lkIjoiYzM1ZWQyYTktYTYzZS00YzAwLThmYmYtY2FlYjlmZjYwMjYwIiwic3ViIjoiYzM1ZWQyYTktYTYzZS00YzAwLThmYmYtY2FlYjlmZjYwMjYwIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvMTNkMTcyMDQtMGRlNi00NTc0LTk4M2EtOTYxYWI5NDNjN2NlLyIsImFwcGlkIjoiNDQ2Y2Y5OTItMDQzYS00YjgxLWJhYzQtY2RlZWYyNGFhNzFjIiwiYXBwaWRhY3IiOiIxIn0.YTGJfdW1wP09bDHwwsv3FPAmEpmQdc_kifvgY-1KjhkZWANfYtd050wfeZdNgMUeSPZyFdWnoBjnJ4xrlDtnsADwV1Grr6TXYcymPLofbY-xy0cjyvzxTmM11DJ9XN8A4tkgvK0jtR-YyIjPw5EKJSKyeEbD9U3mWsE_gu7IzKzXl8e-dfVAqRYS6WHZy6_0FaNmppPDls5s_QIPOHofFSiWVISw41Mz0fQnP2QEGyceOCvKYJtrUOCDwfVuwFS-gSLmYvEGOJfmIjftP3srda0JPirVzBeU0IFJJ1KW81kE5cfKw1KkBB04VVetRUs_7HqloYaKKiTybauhXAodRQ" Wondering if that curl request was flawed somehow, I snooped out an access token “the wrong way” via browser webtools, and the above works fine, returning 200 and a JSON response listing my datasets. I did also notice that the return code is 403 (forbidden), not 401 (unauthorized), so I wondered if the authorization was okay but the permissions on the Power BI side were wrong. But I also get 403 when I use any garbage text for the access token (e.g., Authorization: Bearer foo), so I discarded that theory. So. I think I have a valid test, and I’m getting what I think is a valid access token (from that client-credentials-sample.js code), but it’s still not working. What am I missing? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Authentication needs to be based on a particular user to use Power BI. I tried using: a resource value of https://analysis.windows.net/powerbi/api adding username and password to the parameters.json This was closer, but I was still getting a 400 response: "error_description":"AADSTS90014: The request body must contain the following parameter: 'client_secret or client_assertion'. …". A hack to the adal-node library oauthParameters[OAuth2Parameters.CLIENT_SECRET] = "my-client-secret"; after line 217 of token-request.js) was enough to get back an access token which works in the Authorization header for my original curl call. Fixing that value is not the final solution as we did not plan to use the adal-node library, anyway. But according to proof-of-concept for this authentication case goes. Want to learn more about Power BI, Come & join Power BI tutorial. Also, enroll in Power BI online training to become proficient in this BI tool.

Related questions

0 votes
    I have an ASP.Net core 1.1 website and I want to embed Power BI reports into the site. Azure ... JsonConvert.DeserializeObject(result); Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have an IFrame which shows a PowerBI embedded Report that having a world map. Can I pass a parameter to ... specific country. Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Does anyone know of a way in Power BI to set query parameters as described here from an embed request ... for the visualization. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Does anyone know an implementation case that involves PowerBI and ElasticSearch? I was unable to find any proper documentation. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have written an SQL script which runs fine when executed directly in SQL Management Studio. However, when entering ... are removed: Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I want to parse a .json column through Power BI. I have imported the data directly from the server and ... simplified parsed columns. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    In my application, I'm displaying a Power BI report. It already works, so there's no problem with showing ... dataset in the report? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a HDInsight Hadoop cluster (Linux, deployed separately) on Azure VNet (restricting client IPs using NSG). ... Data Factory? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I have been working on Power BI for a while now and I often get confused when I browse through help topics of ... two. Please guide me. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Can't ping smtp.gmail.com. I've been using google smtp for email notification and it was working ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I am using php oauth2 library from this github repo. PHP oauth2 library Whenever i send a refresh token, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have shared location on Azure VM and web job in the same Vnet on Azure. I have C# script ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I find it difficult to wrap my head around developing a PowerBI visual from scratch. I was reading wiki, guide, ... thanks in advance. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...