Embed Token - Generate Token
為多個報表、數據集和目標工作區產生內嵌令牌。
- 報表和數據集不需要相關。
- 您可以在內嵌期間將報表系結至數據集。
- 您只能在
targetWorkspaces參數指定的工作區中建立報表。
權限
- 使用服務主體進行驗證時,請參閱 使用服務主體內嵌 Power BI 內容,考慮和限制。
- 針對具有編頁視覺效果的Power BI報表,請在API呼叫中包含編頁報表標識符。 如需詳細資訊,請參閱 範例。
- 此 API 呼叫可由服務主體配置檔呼叫。 如需詳細資訊,請參閱:Power BI Embedded中的服務主體配置檔。
必要範圍
除非需求不適用,否則下列所有專案都不適用:
- Content.Create,如果 GenerateTokenRequestV2中指定目標工作區,則為必要專案。
- Report.ReadWrite.All 或 Report.Read.All,如果在 generateTokenRequestV2 中指定報表,則為必要專案。
- Report.ReadWrite.All,如果為 generateTokenRequestV2
allowEdit中至少一個報表指定了 旗標,則為必要項。 - Dataset.ReadWrite.All 或 Dataset.Read.All
局限性
- 您只能在
targetWorkspaces參數指定的工作區中建立報表。 - 所有報表和數據集都必須位於 V2 工作區中。
- 所有目標工作區都必須 V2 工作區。
- 最多 50 份報告。
- 最多50個數據集。
- 最多50個目標工作區。
- 針對 Azure Analysis Services 或 Analysis Services 內部部署即時連線報告,在重新系結 之後,產生具有數據列層級安全性 (RLS) 的內嵌令牌可能無法運作數分鐘。
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
要求本文
| 名稱 | 類型 | Description |
|---|---|---|
| datasets |
數據集清單 |
|
| datasourceIdentities |
線上到已啟用單一 Sign-On (SSO) 的資料源時所要使用的身分識別清單。 |
|
| identities |
要用於數據列層級安全性規則的身分識別清單 |
|
| lifetimeInMinutes |
integer |
令牌的存留期上限,以分鐘為單位,從產生令牌的時間開始。 可以用來縮短令牌的到期時間,但不能加以擴充。 其值必須為正整數。 零 ( |
| reports |
報表清單 |
|
| targetWorkspaces |
內嵌令牌允許儲存的工作區清單 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
還行 |
範例
Example of generating an embed token for a dataset and two reports example. Only one of the reports can be edited.
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229"
}
],
"reports": [
{
"allowEdit": true,
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
},
{
"id": "759908bb-ead8-4a43-9645-7ffbf921c68d"
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2018-07-29T17:58:19Z"
}
Example of generating an embed token for a paginated report which has a Power BI dataset as a datasource. The ID of the dataset must be specified in the request. The report and dataset can each have its own identity
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229",
"xmlaPermissions": "ReadOnly"
}
],
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"identities": [
{
"username": "john@contoso.com",
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-8037-4d0c-896e-a46fb27ff229"
]
},
{
"username": "john@contoso.com",
"reports": [
"b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
]
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2028-07-29T17:58:19Z"
}
Example of generating an embed token for a paginated report with a data source identity
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"datasourceIdentities": [
{
"datasources": [
{
"datasourceType": "Sql",
"connectionDetails": {
"server": "New-Sql-Server",
"database": "New-Sql-Database"
}
}
],
"identityBlob": "eyJ0eX....AAA="
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2028-07-29T17:58:19Z"
}
Example of generating an embed token for a paginated report with multiple data source identities and a single identity blob
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"datasourceIdentities": [
{
"datasources": [
{
"datasourceType": "Sql",
"connectionDetails": {
"server": "New-Sql-Server",
"database": "New-Sql-Database"
}
},
{
"datasourceType": "MySql",
"connectionDetails": {
"server": "New-MySql-Server",
"database": "New-MySql-Database"
}
}
],
"identityBlob": "eyJ0eX....AAA="
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2028-07-29T17:58:19Z"
}
Example of generating an embed token for a paginated report with multiple data source identities and multiple identity blobs
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"datasourceIdentities": [
{
"datasources": [
{
"datasourceType": "Sql",
"connectionDetails": {
"server": "New-Sql-Server",
"database": "New-Sql-Database"
}
}
],
"identityBlob": "eyJ0eX....AAA="
},
{
"datasources": [
{
"datasourceType": "MySql",
"connectionDetails": {
"server": "New-MySql-Server",
"database": "New-MySql-Database"
}
}
],
"identityBlob": "eyJ0dW....AAA="
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2028-07-29T17:58:19Z"
}
Example of generating an embed token for a Power BI report with a dataset which is connected with DirectQuery to another Power BI dataset. All related dataset IDs must be specified in the request with 'xmlaPermissions' set to 'ReadOnly'. IdentityBlobs for all SSO-enabled data sources must be provided in the 'datasourceIdentities' array
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd",
"xmlaPermissions": "ReadOnly"
},
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229",
"xmlaPermissions": "ReadOnly"
}
],
"reports": [
{
"id": "f904e89a-7ebe-4aa0-8647-e409063b4850"
}
],
"datasourceIdentities": [
{
"datasources": [
{
"datasourceType": "Sql",
"connectionDetails": {
"server": "Best-Sql-Server",
"database": "Database3"
}
}
],
"identityBlob": "eyJ0eX....AAA="
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "ab4d49ae-c054-4c29-af52-93b5c80619ff",
"expiration": "2022-06-10T12:41:11Z"
}
Example of generating an embed token for a Power BI report with a paginated visual. The paginated report ID ('...4850') of the paginated visual must be included in the 'reports' section of the request.
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229"
}
],
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
},
{
"id": "f904e89a-7ebe-4aa0-8647-e409063b4850"
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "49ae3742-54c0-4c29-af52-619ff93b5c80",
"expiration": "2018-07-29T17:58:19Z"
}
Example of generating an embed token for two datasets with RLS identities and a single report with read-only permissions. The embed token lets you view the report, which is dynamically bound to two different datasets.
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229"
},
{
"id": "e75afc47-1150-45e0-aba7-4eb04e4876e5"
}
],
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"identities": [
{
"username": "john@contoso.com",
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-8037-4d0c-896e-a46fb27ff229"
]
},
{
"username": "iris@contoso.com",
"roles": [
"executive"
],
"datasets": [
"e75afc47-1150-45e0-aba7-4eb04e4876e5"
]
}
]
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "4b76f5ed-5a06-4150-8d1b-60f8e4c186f4",
"expiration": "2028-07-29T17:58:19Z"
}
Example of generating an embed token that expires no later than ten minutes from the API call
範例要求
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{
"id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229"
}
],
"reports": [
{
"id": "b2e49b01-2356-4456-bfb9-3f4c2bc4ddbd"
}
],
"identities": [
{
"username": "john@contoso.com",
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-8037-4d0c-896e-a46fb27ff229"
]
}
],
"lifetimeInMinutes": 10
}
範例回覆
{
"token": "H4sI....AAA=",
"tokenId": "4b76f5ed-5a06-4150-8d1b-60f8e4c186f4",
"expiration": "2028-07-29T17:58:19Z"
}
定義
| 名稱 | Description |
|---|---|
|
Datasource |
|
|
Datasource |
有效的身分識別,可連接已啟用單一登錄 (SSO) 的 DirectQuery 數據源。 |
|
Datasource |
物件,可透過其連接詳細數據唯一識別單一數據源。 |
|
Effective |
|
|
Embed |
Power BI 內嵌令牌 |
|
Generate |
Power BI 產生令牌要求 V2 |
|
Generate |
GenerateTokenRequestV2 中的數據集物件 |
|
Generate |
generateTokenRequestV2 中的報表物件 |
|
Generate |
GenerateTokenRequestV2 中的工作區物件 |
|
Identity |
指定身分識別的 Blob。 僅支援具有 Azure SQL DirectQuery 連線的數據集 |
|
Xmla |
XMLA 許可權 |
DatasourceConnectionDetails
Power BI 數據源聯機詳細數據。 請參閱 取得數據源 或 在群組中取得數據源中的範例。
| 名稱 | 類型 | Description |
|---|---|---|
| account |
string |
線上帳戶 |
| classInfo |
string |
連接類別資訊 |
| database |
string |
連接資料庫 |
| domain |
string |
線上網域 |
| emailAddress |
string |
線上電子郵件位址 |
| kind |
string |
線上種類 |
| loginServer |
string |
連接登入伺服器 |
| path |
string |
線上路徑 |
| server |
string |
連接伺服器 |
| url |
string |
線上 URL |
DatasourceIdentity
有效的身分識別,可連接已啟用單一登錄 (SSO) 的 DirectQuery 數據源。
| 名稱 | 類型 | Description |
|---|---|---|
| datasources |
套用此身分識別的數據源陣列。 |
|
| identityBlob |
string |
指定身分識別的 Blob。 |
DatasourceSelector
物件,可透過其連接詳細數據唯一識別單一數據源。
| 名稱 | 類型 | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| connectionDetails |
數據源聯機詳細數據。 您可以使用 取得編頁報表的數據源來取得連線詳細數據,取得 powerbi 報表 API 的數據源。 |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| datasourceType |
string |
|
EffectiveIdentity
定義使用者身分識別和角色。 如需詳細資訊,請參閱使用Power BI Embedded 資料列層級安全性。
| 名稱 | 類型 | Description |
|---|---|---|
| auditableContext |
string |
EffectiveIdentity 可稽核內容。 如果提供此參數且不是空的,則會啟用 EffectiveIdentity 的稽核,並將其值設定為稽核記錄中的用戶名稱。 否則,會省略 GenerateToken 稽核記錄中的 EffectiveIdentity 內容。 |
| customData |
string |
用來套用數據列層級安全性規則的自定義數據。 僅支援即時連線至 Azure Analysis Services 模型和雲端模型。 |
| datasets |
string[] |
套用此身分識別的數據集陣列 |
| identityBlob |
指定 身分識別的 Blob。 僅支援具有 Azure SQL DirectQuery 連線的數據集。 |
|
| reports |
string[] |
套用此身分識別的報表數位。 僅支援編頁報表。 |
| roles |
string[] |
套用 RLS 規則之令牌內的數據列層級安全性 (RLS) 角色陣列。 身分識別最多可包含50個角色。 角色可以包含 |
| username |
string |
套用數據列層級安全性規則之令牌內的有效用戶名稱。 針對內部部署模型,用戶名稱可以包含英數位元或任何下列字元, |
EmbedToken
Power BI 內嵌令牌
| 名稱 | 類型 | Description |
|---|---|---|
| expiration |
string (date-time) |
令牌到期的日期和時間 |
| token |
string |
內嵌令牌 |
| tokenId |
string (uuid) |
唯一令牌標識碼。 透過稽核記錄,令牌標識碼可用來將使用令牌與產生作業的作業相互關聯。 |
GenerateTokenRequestV2
Power BI 產生令牌要求 V2
| 名稱 | 類型 | Description |
|---|---|---|
| datasets |
數據集清單 |
|
| datasourceIdentities |
線上到已啟用單一 Sign-On (SSO) 的資料源時所要使用的身分識別清單。 |
|
| identities |
要用於數據列層級安全性規則的身分識別清單 |
|
| lifetimeInMinutes |
integer |
令牌的存留期上限,以分鐘為單位,從產生令牌的時間開始。 可以用來縮短令牌的到期時間,但不能加以擴充。 其值必須為正整數。 零 ( |
| reports |
報表清單 |
|
| targetWorkspaces |
內嵌令牌允許儲存的工作區清單 |
GenerateTokenRequestV2Dataset
GenerateTokenRequestV2 中的數據集物件
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string |
數據集標識碼 |
| xmlaPermissions |
XMLA 許可權 |
GenerateTokenRequestV2Report
generateTokenRequestV2 中的報表物件
| 名稱 | 類型 | Description |
|---|---|---|
| allowEdit |
boolean |
產生的內嵌令牌是否支援報表編輯 |
| id |
string (uuid) |
報表標識碼 |
GenerateTokenRequestV2TargetWorkspace
GenerateTokenRequestV2 中的工作區物件
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string (uuid) |
工作區標識碼 |
IdentityBlob
指定身分識別的 Blob。 僅支援具有 Azure SQL DirectQuery 連線的數據集
| 名稱 | 類型 | Description |
|---|---|---|
| value |
string |
Azure SQL 的 OAuth 2.0 存取令牌 |
XmlaPermissions
XMLA 許可權
| 值 | Description |
|---|---|
| Off |
表示產生的內嵌令牌不會將訪問許可權授與數據集的 XMLA 端點。 |
| ReadOnly |
表示產生的內嵌令牌會將讀取訪問許可權授與數據集的 XMLA 端點。 |