本文整理匯總了TypeScript中powerbi-api.PowerBIToken.createReportEmbedToken方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript PowerBIToken.createReportEmbedToken方法的具體用法?TypeScript PowerBIToken.createReportEmbedToken怎麽用?TypeScript PowerBIToken.createReportEmbedToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類powerbi-api.PowerBIToken
的用法示例。
在下文中一共展示了PowerBIToken.createReportEmbedToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: CliCreateEmbedToken
export default function CliCreateEmbedToken() {
let pkg = require('../package.json');
function list(val) {
return val.split(',');
}
program.version(pkg.version)
.option('-c, --collection <collection>', 'The Power BI workspace collection')
.option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
.option('-w, --workspace <workspaceId>', 'The Power BI workspace id')
.option('-r, --report <reportId>', 'The Power BI report id')
.option('-d, --dataset <datasetId>', 'The Power BI dataset id')
.option('-s, --scopes [scopes]', 'The permission scopes allowed')
.option('-u, --username [username]', 'The RLS username')
.option('--roles [roles]', 'The RLS roles', list)
.option('-e, --expiration <expiration>', 'The token expiration date');
program.on('--help', function () {
console.log(' Examples:');
console.log('');
console.log(' $ powerbi create-embed-token -c <collection>, -w <workspace> -r <reportId> -k <accessKey> -u [username] --roles [roles1,roles2,...]');
console.log(' $ powerbi create-embed-token -c <collection>, -w <workspace> -r <reportId> -k <accessKey> -s [scopes]');
console.log(' $ powerbi create-embed-token -c <collection>, -w <workspace> -d <datasetId> -k <accessKey> -s [scopes]');
console.log(' Create report in embedded view needs the following scopes: "Dataset.Read Workspace.Report.Create"');
});
program.parse(process.argv);
let settings = config.merge(program);
if (!(settings.collection && settings.accessKey)) {
program.help();
} else {
try {
let token: powerbi.PowerBIToken = null;
if (!settings.accessKey) {
return cli.error('Access key param is required');
}
if (!(settings.collection && settings.workspace)) {
return cli.error('collection and workspace params are required');
}
if (!(settings.report || settings.dataset)) {
return cli.error('Either reportId or datasetId must be set');
}
let expiration = settings.expiration ? new Date(settings.expiration) : void 0;
token = powerbi.PowerBIToken.createReportEmbedToken(settings.collection, settings.workspace, settings.report, settings.dataset, settings.scopes, settings.username, settings.roles, expiration);
let jwt = token.generate(settings.accessKey);
cli.success('Embed Token: ', jwt);
} catch (err) {
cli.error(err);
}
}
}
示例2: CliCreateToken
export default function CliCreateToken() {
let err;
let program = require('commander');
let colors = require('colors');
let pkg = require('../package.json');
let util = require('util');
program.version(pkg.version)
.option('-c, --collection <collection>', 'The Power BI workspace collection')
.option('-k, --accessKey <accessKey>', 'The Power BI workspace collection access key')
.option('-t, --tokenType <tokenType>', 'The type of token to generate')
.option('-w, --workspace [workspaceId]', 'The Power BI workspace id')
.option('-r, --report [reportId]', 'The Power BI report id');
program.on('--help', function () {
console.log(' Examples:');
console.log('');
console.log(' $ powerbi create-token -c <collection>, -w <workspace> -r <report> -k <accessKey>');
});
program.parse(process.argv);
let settings = config.merge(program);
if (!(settings.collection && settings.accessKey)) {
program.help();
} else {
try {
let tokenType: string = null;
let token: powerbi.PowerBIToken = null;
if (!settings.tokenType) {
return cli.error('tokenType param is required');
}
if (!settings.accessKey) {
return cli.error('Access key param is required');
}
switch (settings.tokenType.toLowerCase()) {
case 'embed':
if (!(settings.collection && settings.workspace && settings.report)) {
return cli.error('collection, workspace and report params are required');
}
token = powerbi.PowerBIToken.createReportEmbedToken(settings.collection, settings.workspace, settings.report);
break;
case 'dev':
if (!(settings.collection && settings.workspace)) {
return cli.error('collection & workspace params are required');
}
token = powerbi.PowerBIToken.createDevToken(settings.collection, settings.workspace);
break;
case 'provision':
if (!(settings.collection && settings.workspace)) {
return cli.error('collection param is required');
}
token = powerbi.PowerBIToken.createProvisionToken(settings.collection);
break;
default:
return cli.error('Unknown tokenType specified. Options: provision, dev, embed');
}
let jwt = token.generate(settings.accessKey);
cli.success('%s: ', settings.tokenType, jwt);
} catch (err) {
cli.error(err);
}
}
}