/// <summary>
 /// Generates an embed token for multiple reports, datasets and target
 /// workspaces. Reports and datasets do not have to be related. The binding of
 /// a report to a dataset can be done during embedding. Target workspaces are
 /// workspaces where creation of reports is allowed.&lt;br/&gt;This API is
 /// relevant only to ['App owns data' embed
 /// scenario](https://docs.microsoft.com/power-bi/developer/embed-sample-for-customers).
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: &lt;ul&gt;&lt;li&gt;Content.Create -
 /// required only if a target workspace is specified in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Report.ReadWrite.All
 /// or Report.Read.All - required only if a report is specified in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Report.ReadWrite.All
 /// - required if allowEdit flag is specified for at least one report in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Dataset.ReadWrite.All
 /// or Dataset.Read.All&lt;/li&gt;&lt;/ul&gt;To set the permissions scope, see
 /// [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).&lt;/br&gt;&lt;/br&gt;When
 /// using service principal for authentication, refer to [Service Principal
 /// with Power
 /// BI](https://docs.microsoft.com/power-bi/developer/embed-service-principal)
 /// document along with considerations and limitations section.
 /// &lt;h2&gt;Restrictions&lt;/h2&gt;&lt;li&gt;All the reports and datasets
 /// must reside in workspace V2. All the target workpaces must be workspace
 /// V2.&lt;/li&gt;&lt;li&gt;Maximum number of reports, datasets and target
 /// workspaces is 50 each.&lt;/li&gt;&lt;li&gt;Generating Embed Token with RLS
 /// may not work for AS Azure or AS OnPrem live connection reports for several
 /// minutes after a
 /// [Rebind](/rest/api/power-bi/reports/RebindReport).&lt;/li&gt;&lt;br/&gt;
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='requestParameters'>
 /// Generate token parameters
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <EmbedToken> GenerateTokenAsync(this IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GenerateTokenWithHttpMessagesAsync(requestParameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #2
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Datasets                = new DatasetsOperations(this);
     Users                   = new Users(this);
     Imports                 = new ImportsOperations(this);
     Reports                 = new ReportsOperations(this);
     Dashboards              = new DashboardsOperations(this);
     Tiles                   = new TilesOperations(this);
     Apps                    = new AppsOperations(this);
     Dataflows               = new DataflowsOperations(this);
     Gateways                = new GatewaysOperations(this);
     Groups                  = new GroupsOperations(this);
     Capacities              = new CapacitiesOperations(this);
     AvailableFeatures       = new AvailableFeaturesOperations(this);
     DataflowStorageAccounts = new DataflowStorageAccountsOperations(this);
     Admin                   = new Admin(this);
     EmbedToken              = new EmbedTokenOperations(this);
     BaseUri                 = new System.Uri("https://api.powerbi.com");
     SerializationSettings   = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
 /// <summary>
 /// Generates an embed token for multiple reports, datasets and target
 /// workspaces. Reports and datasets do not have to be related. The binding of
 /// a report to a dataset can be done during embedding. Target workspaces are
 /// workspaces where creation of reports is allowed.&lt;br/&gt;This API is
 /// relevant only to ['App owns data' embed
 /// scenario](https://docs.microsoft.com/power-bi/developer/embed-sample-for-customers).
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: &lt;ul&gt;&lt;li&gt;Content.Create -
 /// required only if a target workspace is specified in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Report.ReadWrite.All
 /// or Report.Read.All - required only if a report is specified in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Report.ReadWrite.All
 /// - required if allowEdit flag is specified for at least one report in
 /// [GenerateTokenRequestV2](/rest/api/power-bi/embedtoken/generatetoken#generatetokenrequestv2)&lt;/li&gt;&lt;li&gt;Dataset.ReadWrite.All
 /// or Dataset.Read.All&lt;/li&gt;&lt;/ul&gt;To set the permissions scope, see
 /// [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).&lt;/br&gt;&lt;/br&gt;When
 /// using service principal for authentication, refer to [Service Principal
 /// with Power
 /// BI](https://docs.microsoft.com/power-bi/developer/embed-service-principal)
 /// document along with considerations and limitations section.
 /// &lt;h2&gt;Restrictions&lt;/h2&gt;&lt;li&gt;All the reports and datasets
 /// must reside in workspace V2. All the target workpaces must be workspace
 /// V2.&lt;/li&gt;&lt;li&gt;Maximum number of reports, datasets and target
 /// workspaces is 50 each.&lt;/li&gt;&lt;li&gt;Generating Embed Token with RLS
 /// may not work for AS Azure or AS OnPrem live connection reports for several
 /// minutes after a
 /// [Rebind](/rest/api/power-bi/reports/RebindReport).&lt;/li&gt;&lt;br/&gt;
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='requestParameters'>
 /// Generate token parameters
 /// </param>
 public static EmbedToken GenerateToken(this IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters)
 {
     return(operations.GenerateTokenAsync(requestParameters).GetAwaiter().GetResult());
 }