我試圖在另一個服務(作爲數據源)和Microsoft Power BI之間創建一個橋樑。但是,我無法使REST API正常工作。Power BI REST身份驗證和權限
到目前爲止,我已經成功地在Azure AD中創建了一個Web應用程序,獲取客戶端ID和祕密,接收API的訪問令牌,但在此之後,我得到的所有內容均爲403 Forbidden
,沒有錯誤消息。但是,如果我嘗試使用過期令牌訪問API,則會收到一條錯誤消息,告訴我令牌已過期。
我已經閱讀了關於這個主題的一些文章,但是他們都表示,如果沒有用戶登錄並首先訪問Power BI,就無法訪問REST API,這在服務到服務應用程序中是不可能的。
如何在沒有任何用戶交互的情況下正確訪問服務?
這裏是請求和回覆,有一點審查。
請求1:
POST /[our domain].com/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: flight-uxoptin=true; stsservicecookie=ests; x-ms-gateway-slice=productiona; stsservicecookie=ests
Host: login.microsoftonline.com
Connection: close
User-Agent: Paw/2.3 (Macintosh; OS X/10.11.3) GCDHTTPRequest
Content-Length: 203
grant_type=client_credentials&client_id=[client id]&client_secret=[client secret]&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi
響應1:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
x-ms-request-id: 52d6713c-d50b-4073-b030-aa10e33fdf27
client-request-id: 3aef4765-d602-46a6-a8ce-4b7792f678e5
x-ms-gateway-service-instanceid: ESTSFE_IN_209
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
Set-Cookie: x-ms-gateway-slice=productiona; path=/; secure; HttpOnly
Set-Cookie: stsservicecookie=ests; path=/
X-Powered-By: ASP.NET
Date: Wed, 24 Feb 2016 08:24:29 GMT
Connection: close
Content-Length: 1243
{"token_type":"Bearer","expires_in":"3599","expires_on":"1456305870","not_before":"1456301970","resource":"https://analysis.windows.net/powerbi/api","access_token":"[access token]"}
請求2:
GET /v1.0/myorg/datasets HTTP/1.1
Authorization: Bearer [access token]
Content-Length: 0
Host: api.powerbi.com
Connection: close
User-Agent: Paw/2.3 (Macintosh; OS X/10.11.3) GCDHTTPRequest
響應2:
HTTP/1.1 403 Forbidden
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: deny
X-Content-Type-Options: nosniff
RequestId: 803cc0cb-c65d-4212-9ab8-aed4ffa9862a
Date: Wed, 24 Feb 2016 08:25:13 GMT
Connection: close
嗨onik,你有沒有得到任何解決方案獲得訪問令牌。我面臨類似的問題。 –
不,我沒有進一步調查,我們決定使用Azure SQL將數據導入Power BI。 – onik