Updating SDK to use v1.0 APIS:
- update beta -> v1.0 - update documentation - remove unused dev and provision tokens
This commit is contained in:
Родитель
5685fe25a6
Коммит
d5c76da9da
56
README.md
56
README.md
|
@ -12,8 +12,7 @@ Creating a new client requires referencing the Power BI SDK as well as the Micro
|
|||
var powerbi = require('powerbi-api');
|
||||
var msrest = require('ms-rest');
|
||||
|
||||
var token = powerbi.PowerBIToken.createProvisionToken('{WorkspaceCollection}');
|
||||
var credentials = new msrest.TokenCredentials(token.generate('{AccessKey}'), 'AppToken');
|
||||
var credentials = new msrest.TokenCredentials('{AccessKey}', "AppKey");
|
||||
var client = new powerbi.PowerBIClient(credentials);
|
||||
|
||||
// Example API call
|
||||
|
@ -30,49 +29,25 @@ The following APIs groups are available:
|
|||
- Reports
|
||||
- Workspaces
|
||||
|
||||
## Creating App Tokens
|
||||
Power BI Embedded supports 3 flavors of app tokens each with seperate requirements. All tokens are HMAC signed JSON Web Tokens. The tokens are signed with the access key from your Azure Power BI Embedded workspace collection.
|
||||
## PowerBI API Calls
|
||||
All API calls use the AppKey to authenticate the API calls. The AppKey can be retreived from Azure portal.
|
||||
Each API call sets the following HTTP header:
|
||||
- Authorization: AppKey {AccessKey}
|
||||
|
||||
**WARNING** - Never expose your access keys client side in your application. If your access key is compromised a malicious user can take over control of your workspace collection. Access keys can be re-generated for your workspace collection within the Azure portal.
|
||||
|
||||
### Required Claims
|
||||
- ver: 0.1.0
|
||||
- aud: https://analysis.windows.net/powerbi/api
|
||||
- type: provision | dev | embed
|
||||
- nbp: Token valid not before in Unix EPOCH time
|
||||
- exp: Token expiration in Unix EPOCH time
|
||||
|
||||
### Provision Token
|
||||
Provision tokens are used to manage the root of your workspace collection.
|
||||
#### Required Claims
|
||||
- wcn: {WorkspaceCollectionName}
|
||||
|
||||
```javascript
|
||||
var powerbi = require('powerbi-api');
|
||||
var token = powerbi.PowerBIToken.createProvisionToken('{WorkspaceCollection}');
|
||||
|
||||
var jwt = token.generate('{AccessKey}');
|
||||
```
|
||||
|
||||
### Dev Token
|
||||
Dev tokens are used to make scoped calls into a workspace within your collection.
|
||||
#### Required Claims
|
||||
- wcn: {WorkspaceCollectionName}
|
||||
- wid: {WorkspaceId}
|
||||
|
||||
```javascript
|
||||
var powerbi = require('powerbi-api');
|
||||
var token = powerbi.PowerBIToken.createDevToken('{WorkspaceCollection}', '{workspaceId}');
|
||||
|
||||
var jwt = token.generate('{AccessKey}');
|
||||
```
|
||||
|
||||
### Embed Token
|
||||
## Creating Embed Tokens
|
||||
Power BI Embedded uses embed token, which are HMAC signed JSON Web Tokens. The tokens are signed with the access key from your Azure Power BI Embedded workspace collection.
|
||||
Embed tokens are used to provide read only access to a report to embed into an application.
|
||||
#### Required Claims
|
||||
|
||||
### Required Claims
|
||||
- ver: 0.2.0
|
||||
- wcn: {WorkspaceCollectionName}
|
||||
- wid: {WorkspaceId}
|
||||
- rid: {ReportId}
|
||||
- aud: https://analysis.windows.net/powerbi/api
|
||||
- nbp: Token valid not before in Unix EPOCH time
|
||||
- exp: Token expiration in Unix EPOCH time
|
||||
|
||||
```javascript
|
||||
var powerbi = require('powerbi-api');
|
||||
|
@ -82,7 +57,7 @@ var jwt = token.generate('{AccessKey}');
|
|||
```
|
||||
|
||||
## Token Example
|
||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiOiIwLjEuMCIsInR5cGUiOiJlbWJlZCIsIndjbiI6IlN1cHBvcnREZW1vIiwid2lkIjoiY2E2NzViMTktNmMzYy00MDAzLTg4MDgtMWM3ZGRjNmJkODA5IiwicmlkIjoiOTYyNDFmMGYtYWJhZS00ZWE5LWEwNjUtOTNiNDI4ZWRkYjE3IiwiaXNzIjoiUG93ZXJCSVNESyIsImF1ZCI6Imh0dHBzOi8vYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9hcGkiLCJleHAiOjEzNjAwNDcwNTYsIm5iZiI6MTM2MDA0MzQ1Nn0.WzOQJW_0n7NLfsr7UelWwljAF2kDAYXZEevMwa4ODo8
|
||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiOiIwLjIuMCIsIndjbiI6IlN1cHBvcnREZW1vIiwid2lkIjoiY2E2NzViMTktNmMzYy00MDAzLTg4MDgtMWM3ZGRjNmJkODA5IiwicmlkIjoiOTYyNDFmMGYtYWJhZS00ZWE5LWEwNjUtOTNiNDI4ZWRkYjE3IiwiaXNzIjoiUG93ZXJCSVNESyIsImF1ZCI6Imh0dHBzOi8vYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9hcGkiLCJleHAiOjEzNjAwNDcwNTYsIm5iZiI6MTM2MDA0MzQ1Nn0.LgG2y0m24gg3vjQHhkXYYWKSVnGIUYT-ycA6JmTB6tg
|
||||
|
||||
### Decoded
|
||||
The following decoded JSON web token
|
||||
|
@ -97,8 +72,7 @@ The following decoded JSON web token
|
|||
**Payload**
|
||||
```javascript
|
||||
{
|
||||
"ver": "0.1.0",
|
||||
"type": "embed",
|
||||
"ver": "0.2.0",
|
||||
"wcn": "SupportDemo",
|
||||
"wid": "ca675b19-6c3c-4003-8808-1c7ddc6bd809",
|
||||
"rid": "96241f0f-abae-4ea9-a065-93b428eddb17",
|
||||
|
|
|
@ -73,7 +73,7 @@ export class Imports implements operations.Imports {
|
|||
}
|
||||
|
||||
// Construct URL
|
||||
var requestUrl = this.client['baseUri'] + '//beta/collections/{collectionName}/workspaces/{workspaceId}/imports';
|
||||
var requestUrl = this.client['baseUri'] + '//v1.0/collections/{collectionName}/workspaces/{workspaceId}/imports';
|
||||
requestUrl = requestUrl.replace('{collectionName}', encodeURIComponent(collectionName));
|
||||
requestUrl = requestUrl.replace('{workspaceId}', encodeURIComponent(workspaceId));
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import {ServiceClientCredentials, ServiceClientOptions} from 'ms-rest';
|
|||
export class PowerBIClient extends AutorestClient {
|
||||
public imports:operations.Imports;
|
||||
|
||||
constructor(credentials: ServiceClientCredentials, baseUri: string, options?: ServiceClientOptions) {
|
||||
constructor(credentials: ServiceClientCredentials, baseUri: string='https://api.powerbi.com', options?: ServiceClientOptions) {
|
||||
super(credentials, baseUri, options);
|
||||
this.imports = new operations.Imports(this);
|
||||
}
|
||||
|
|
|
@ -8,32 +8,14 @@ export class PowerBIToken {
|
|||
constructor(expiration?: Date) {
|
||||
this.expiration = expiration;
|
||||
this.claims = {
|
||||
ver: '0.1.0',
|
||||
ver: '0.2.0',
|
||||
aud: 'https://analysis.windows.net/powerbi/api',
|
||||
iss: 'Power BI Node SDK'
|
||||
};
|
||||
}
|
||||
|
||||
public static createDevToken(workspaceCollectionName: string, workspaceId: string, expiration: Date = null): PowerBIToken {
|
||||
var token = new PowerBIToken(expiration);
|
||||
token.addClaim('type', 'dev');
|
||||
token.addClaim('wcn', workspaceCollectionName);
|
||||
token.addClaim('wid', workspaceId);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public static createProvisionToken(workspaceCollectionName: string, expiration: Date = null): PowerBIToken {
|
||||
var token = new PowerBIToken(expiration);
|
||||
token.addClaim('type', 'provision');
|
||||
token.addClaim('wcn', workspaceCollectionName);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public static createReportEmbedToken(workspaceCollectionName: string, workspaceId: string, reportId: string, expiration: Date = null): PowerBIToken {
|
||||
var token = new PowerBIToken(expiration);
|
||||
token.addClaim('type', 'embed');
|
||||
token.addClaim('wcn', workspaceCollectionName);
|
||||
token.addClaim('wid', workspaceId);
|
||||
token.addClaim('rid', reportId);
|
||||
|
|
Загрузка…
Ссылка в новой задаче