久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

客戶端憑據不適用于 powerBI REST API

Client-credentials don#39;t work for powerBI REST API(客戶端憑據不適用于 powerBI REST API)
本文介紹了客戶端憑據不適用于 powerBI REST API的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試實現守護程序身份驗證流程.以下發布請求返回給我一個具有正確范圍的訪問令牌:

p_url = 'https://login.microsoftonline.com/' + 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + '/oauth2/token'數據 = {'grant_type':'client_credentials','client_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','client_secret': 'L--------------------------------------------------------=','資源':'https://analysis.windows.net/powerbi/api'}r = requests.post(url=p_url, 數據=數據)

我收到以下回復

<代碼>{access_token":ey------------"expires_on":1454857253",not_before":1454853353","expires_in" : "3600","token_type" : "承載者","scope" : "Dashboard.Read.All Data.Alter_Any Dataset.Read.All Dataset.ReadWrite.All Report.Read.All",資源":https://analysis.windows.net/powerbi/api"}響應 = json.loads(r.text)令牌 = 響應 ['access_token']標頭= {'授權':'承載'+令牌}response = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=headers)

我使用應用程序查看端點"頁面中的端點.但是,當我嘗試獲取數據集"列表時,我總是收到 403.獲取令牌過程中可能缺少什么?

解決方案

你的流程有點短.對數據集的 REST 調用似乎還可以,但據我所知,您必須通過授權代碼請求訪問令牌,而不僅僅是客戶端憑據.

1) 獲取授權碼

取決于您的流程,對于網站,它將在登錄過程中收到或使用 { 'response_type':'code } 調用/oauth2/authorize

2) 獲取訪問令牌

使用變量中的授權碼,您必須修改您的請求以包含授權碼,如下所示(grant_type 和 code 字段已更改):

p_url = 'https://login.microsoftonline.com/' + 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + '/oauth2/token'數據 = { 'grant_type':'authorization_code','client_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx','client_secret': 'L--------------------------------------------------------=','代碼':authorizationCodeForSingedInUser,'資源':'https://analysis.windows.net/powerbi/api'}r = requests.post(url=p_url, 數據=數據)

基本上,您必須擁有一個可以訪問 Power BI 資源的用戶帳戶.您的網站(clientid + secret)未經授權.必須有用戶參與.

更重要的是,afaik 只有組織帳戶"用戶才能訪問 power bi.

明確并強調此線程、帖子和評論中的主要原因:Power BI REST API 只能通過具有組織帳戶憑據的用戶使用,并且已在 Power BI 門戶.您可以通過檢查此用戶是否能夠手動使用 Power BI 門戶 來檢查 REST Api 是否可以工作.p>

I'm trying to implement the daemon authentication flow. The following post request returns me an access token with the right scope:

p_url = 'https://login.microsoftonline.com/' + 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + '/oauth2/token'
data = { 'grant_type':'client_credentials',
         'client_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
         'client_secret': 'L------------------------------------------=',
         'resource':'https://analysis.windows.net/powerbi/api' }
r = requests.post(url=p_url, data=data)

I receive the following response

{
  "access_token" : "ey------------"
  "expires_on" : "1454857253",
  "not_before" : "1454853353",
  "expires_in" : "3600",
  "token_type" : "Bearer",
  "scope" : "Dashboard.Read.All Data.Alter_Any Dataset.Read.All Dataset.ReadWrite.All Report.Read.All",
  "resource" : "https://analysis.windows.net/powerbi/api"
}

response = json.loads(r.text)
token = response['access_token']
headers = { 'Authorization': 'Bearer ' + token }
response = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=headers)

I use the endpoint from the applications "view endpoints" page. However, when I attempt to get list of "datasets" I always receive 403. What might be missing from the acquire token process?

解決方案

Your flow is a bit short. REST call for datasets seems OK, but as far as I know, you have to request the access token by authorization code, not client credentials alone.

1) Get authorization code

Depends on your flow, for website it will be received during logon process or call to /oauth2/authorize with { 'response_type':'code }

2) Get access token

With authorization code in a variable, you have to modify your request to include to authorization code, like this (grant_type and code fields are altered):

p_url = 'https://login.microsoftonline.com/' + 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + '/oauth2/token'
data = { 'grant_type':'authorization_code',
     'client_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
     'client_secret': 'L------------------------------------------=',
     'code': authorizationCodeForSingedInUser,
     'resource':'https://analysis.windows.net/powerbi/api' }
r = requests.post(url=p_url, data=data)

Basically saying, you have to have a user account that accesses the Power BI resource. Your website (clientid + secret) are not authorized by itself. There must be a user involved.

What's more, afaik only "organization account" users can access power bi.

To be explicit and underline the main cause in this thread, post and comments: Power BI REST API can only be used via User with credentials with Organizational Account and be already signed in (activated) Power BI on Power BI portal. You can check if REST Api will work by checking if this user is able to use Power BI portal manually.

這篇關于客戶端憑據不適用于 powerBI REST API的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節點)
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 免费一区二区 | 国产日产精品一区二区三区四区 | 香蕉av免费 | 国产激情在线 | 亚洲精品3 | 国产精品三级久久久久久电影 | 国产一区二区三区四区区 | 国产色婷婷精品综合在线手机播放 | 黄色一级在线播放 | 91视频国产区 | 精品www| 国产精品夜色一区二区三区 | 国产一区视频在线 | 精品国产黄色片 | 亚洲在线一区 | 99精品欧美一区二区蜜桃免费 | 亚洲精品久久久久久久久久久 | 亚洲一区二区av | 毛片入口 | 国产粉嫩尤物极品99综合精品 | 中文字幕日韩欧美一区二区三区 | 国产三级大片 | 在线日韩中文字幕 | 国产三区视频在线观看 | 天堂亚洲| 午夜影院 | 亚洲成人免费视频在线观看 | 久久小视频 | 色999视频| 久久久成人免费视频 | 日韩欧美国产一区二区 | 国产日韩免费观看 | 国产精品久久国产精品 | 欧美精品一区二区三区在线 | 麻豆精品国产免费 | 精品国产乱码一区二区三 | 羞羞视频网站免费观看 | 可以在线看的黄色网址 | 日韩黄色小视频 | 日操夜操 | 美女爽到呻吟久久久久 |