1

I'm trying to use the Power BI REST API to embed some reports on my site. To do this using an access token acquired by "client credentials" method, but all the requests I'm doing the API denies by 403 codes.

I'm using PHP with curl, but to make it more readable I'll provide samples using curl client.

  • Get Access Token Code:

    curl -X POST "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "client_id=4dd507e4-XXXX-XXX-8410-ce6853edf48a" -F "client_secret=i/0YIhvBa(...)/Y%3D" -F "grant_type=client_credentials" "https://login.microsoftonline.com/$myorg/oauth2/token"

  • API Call (Get Reports for example):

    curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLC(...)4QzVw" "Cache-Control: no-cache" "https://api.powerbi.com/v1.0/myorg/reports"

It should follow this flow:

+---------+                                  +---------------+
:         :                                  :               :
:         :>-- A - Client Authentication --->: Authorization :
: Client  :                                  :     Server    :
:         :<-- B ---- Access Token ---------<:               :
:         :                                  :               :
+---------+                                  +---------------+

PS: I found a similar question but this one isn't on same scope, language and append username and password isn't an option because isn't a personal application.

Attachement: https://powerbi.microsoft.com/en-us/documentation/

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
LeonanCarvalho
  • 1,819
  • 3
  • 20
  • 39
  • And doesn't works with curl cli, right? – Hackerman Dec 01 '16 at 19:13
  • Get access token works but make calls on API no. Neither on client or php curl. – LeonanCarvalho Dec 01 '16 at 19:18
  • On this url: https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-authenticate-a-client-app/ you need to follow the `What you need to authenticate a Power BI client app` steps first. – Hackerman Dec 01 '16 at 19:30
  • I posted this same link as attachment of this question. I think it's outdated because "https://analysis.windows.net/powerbi/api" isn't available. – LeonanCarvalho Dec 01 '16 at 20:06
  • Is not the same link...unless that the link that you provided was cutted somehow in your question...your link redirects to `https://powerbi.microsoft.com/en-us/documentation/` – Hackerman Dec 01 '16 at 20:09
  • I assume that you know how OAuth works...when you register your app, you provided a callback url, right...so your access token it's a valid token from petitions for that url-domain only....that's why your curl cli request fails – Hackerman Dec 01 '16 at 20:12
  • @Hackerman It make sense IF i'm using another grant, but ofr client_credential does not. It was designer to service calls or calls on behalf of the user who created the client requesting access to the protected resources under its control, or those of another resource owner that have been previously arranged with the authorization server. Or I'm wrong? – LeonanCarvalho Dec 01 '16 at 20:38
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/129576/discussion-between-leonancarvalho-and-hackerman). – LeonanCarvalho Dec 01 '16 at 20:39

0 Answers0