├── .gitignore ├── App Owns Data ├── PowerBIEmbedded_AppOwnsData.sln └── PowerBIEmbedded_AppOwnsData │ ├── App_Start │ ├── BundleConfig.cs │ ├── FilterConfig.cs │ └── RouteConfig.cs │ ├── Cloud.config │ ├── CloudConfigs │ ├── Power BI DoD Contractors │ │ └── Cloud.config │ ├── Power BI DoD │ │ └── Cloud.config │ ├── Power BI Global │ │ └── Cloud.config │ ├── Power BI US Government │ │ └── Cloud.config │ ├── Power BI in Germany │ │ └── Cloud.config │ └── Power BI operated by 21Vianet in China │ │ └── Cloud.config │ ├── Content │ └── style │ │ └── style.css │ ├── Controllers │ └── HomeController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── Models │ ├── EmbedConfig.cs │ └── TileEmbedConfig.cs │ ├── PowerBIEmbedded_AppOwnsData.csproj │ ├── Project_Readme.html │ ├── Properties │ └── AssemblyInfo.cs │ ├── Scripts │ ├── powerbi.js │ ├── powerbi.js.map │ └── powerbi.min.js │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── EmbedDashboard.cshtml │ │ ├── EmbedReport.cshtml │ │ ├── EmbedTile.cshtml │ │ ├── Index.cshtml │ │ └── LiveDemoLink.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── Web.config │ └── _ViewStart.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── favicon.ico │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff │ └── packages.config ├── Install-Package ├── LICENSE ├── README.md └── User Owns Data ├── CloudConfigs ├── Power BI Global │ └── Cloud.config ├── Power BI US Government │ └── Cloud.config ├── Power BI in Germany │ └── Cloud.config └── Power BI operated by 21Vianet in China │ └── Cloud.config ├── integrate-dashboard-web-app ├── PBIWebApp (Dashboards Sample).sln ├── PBIWebApp │ ├── App_Start │ │ └── RouteConfig.cs │ ├── Cloud.config │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── PBIWebApp.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Site.Master │ ├── Site.Master.cs │ ├── Site.Master.designer.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── css │ │ └── master.css │ ├── packages.config │ ├── redirect.aspx │ ├── redirect.aspx.cs │ ├── redirect.aspx.designer.cs │ └── scripts │ │ ├── powerbi.js │ │ ├── powerbi.js.map │ │ └── powerbi.min.js └── README.md ├── integrate-report-web-app ├── PBIWebApp │ ├── App_Start │ │ └── RouteConfig.cs │ ├── Cloud.config │ ├── Default.aspx │ ├── Default.aspx.cs │ ├── Default.aspx.designer.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── PBIWebApp.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Site.Master │ ├── Site.Master.cs │ ├── Site.Master.designer.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── css │ │ └── master.css │ ├── packages.config │ └── scripts │ │ ├── powerbi.js │ │ ├── powerbi.js.map │ │ └── powerbi.min.js ├── README.md └── pbi-saas-embed-report.sln └── integrate-tile-web-app ├── PBIWebApp ├── App_Start │ └── RouteConfig.cs ├── Cloud.config ├── Default.aspx ├── Default.aspx.cs ├── Default.aspx.designer.cs ├── Global.asax ├── Global.asax.cs ├── PBIWebApp.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Settings.Designer.cs │ └── Settings.settings ├── Site.Master ├── Site.Master.cs ├── Site.Master.designer.cs ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── css │ └── master.css └── packages.config ├── README.md └── pbi-saas-embed-tile.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerBIEmbedded_AppOwnsData", "PowerBIEmbedded_AppOwnsData\PowerBIEmbedded_AppOwnsData.csproj", "{272D6B69-0644-477B-AAB8-51C71E54E208}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {272D6B69-0644-477B-AAB8-51C71E54E208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {272D6B69-0644-477B-AAB8-51C71E54E208}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {272D6B69-0644-477B-AAB8-51C71E54E208}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {272D6B69-0644-477B-AAB8-51C71E54E208}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace PowerBIEmbedded_AppOwnsData 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 18 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 19 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 20 | "~/Scripts/modernizr-*")); 21 | 22 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 23 | "~/Scripts/bootstrap.js", 24 | "~/Scripts/respond.js")); 25 | 26 | bundles.Add(new StyleBundle("~/Content/css").Include( 27 | "~/Content/bootstrap.css", 28 | "~/Content/site.css")); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace PowerBIEmbedded_AppOwnsData 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace PowerBIEmbedded_AppOwnsData 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI DoD Contractors/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI DoD/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI Global/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI US Government/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI in Germany/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/CloudConfigs/Power BI operated by 21Vianet in China/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Content/style/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: 'Segoe UI Web Light', 'Segoe UI Light', 'Segoe WP Light', 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif 3 | } 4 | 5 | #reportContainer { 6 | height: 600px; 7 | width: 100%; 8 | max-width: 1000px; 9 | } 10 | 11 | #dashboardContainer { 12 | height: 920px; 13 | width: 100%; 14 | max-width: 1320px; 15 | } 16 | 17 | #dashboardContainer iframe{ 18 | border: none; 19 | } 20 | 21 | #buttonsWrapper { 22 | width: 100%; 23 | text-align: center; 24 | padding-top: 50px; 25 | } 26 | 27 | a:hover, a:visited, a:link, a:active { 28 | text-decoration: none; 29 | cursor: pointer; 30 | } 31 | 32 | #buttonsWrapper a { 33 | background-color: rgb(36, 169, 225); 34 | border: none; 35 | color: white; 36 | padding: 5px 30px; 37 | margin: 5px; 38 | width: 200px; 39 | height: 30px; 40 | display: inline-block; 41 | text-align: center; 42 | } 43 | 44 | #buttonsWrapper a:hover { 45 | font-size: 120%; 46 | } 47 | 48 | #tileContainer { 49 | width: 400px; 50 | height: 350px; 51 | } 52 | 53 | .infoBox { 54 | margin-top: 30px; 55 | } -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 2 | using Microsoft.PowerBI.Api.V2; 3 | using Microsoft.PowerBI.Api.V2.Models; 4 | using Microsoft.Rest; 5 | using PowerBIEmbedded_AppOwnsData.Models; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Configuration; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | using System.Web.Mvc; 12 | 13 | namespace PowerBIEmbedded_AppOwnsData.Controllers 14 | { 15 | public class HomeController : Controller 16 | { 17 | private static readonly string Username = ConfigurationManager.AppSettings["pbiUsername"]; 18 | private static readonly string Password = ConfigurationManager.AppSettings["pbiPassword"]; 19 | private static readonly string AuthorityUrl = ConfigurationManager.AppSettings["authorityUrl"]; 20 | private static readonly string ResourceUrl = ConfigurationManager.AppSettings["resourceUrl"]; 21 | private static readonly string ApplicationId = ConfigurationManager.AppSettings["ApplicationId"]; 22 | private static readonly string ApiUrl = ConfigurationManager.AppSettings["apiUrl"]; 23 | private static readonly string WorkspaceId = ConfigurationManager.AppSettings["workspaceId"]; 24 | private static readonly string ReportId = ConfigurationManager.AppSettings["reportId"]; 25 | 26 | public ActionResult Index() 27 | { 28 | return View(); 29 | } 30 | 31 | public async Task EmbedReport(string username, string roles) 32 | { 33 | var result = new EmbedConfig(); 34 | try 35 | { 36 | result = new EmbedConfig { Username = username, Roles = roles }; 37 | var error = GetWebConfigErrors(); 38 | if (error != null) 39 | { 40 | result.ErrorMessage = error; 41 | return View(result); 42 | } 43 | 44 | // Create a user password cradentials. 45 | var credential = new UserPasswordCredential(Username, Password); 46 | 47 | // Authenticate using created credentials 48 | var authenticationContext = new AuthenticationContext(AuthorityUrl); 49 | var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential); 50 | 51 | if (authenticationResult == null) 52 | { 53 | result.ErrorMessage = "Authentication Failed."; 54 | return View(result); 55 | } 56 | 57 | var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer"); 58 | 59 | // Create a Power BI Client object. It will be used to call Power BI APIs. 60 | using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) 61 | { 62 | // Get a list of reports. 63 | var reports = await client.Reports.GetReportsInGroupAsync(WorkspaceId); 64 | 65 | // No reports retrieved for the given workspace. 66 | if(reports.Value.Count() == 0) 67 | { 68 | result.ErrorMessage = "No reports were found in the workspace"; 69 | return View(result); 70 | } 71 | 72 | Report report; 73 | if (string.IsNullOrWhiteSpace(ReportId)) 74 | { 75 | // Get the first report in the workspace. 76 | report = reports.Value.FirstOrDefault(); 77 | } 78 | else 79 | { 80 | report = reports.Value.FirstOrDefault(r => r.Id == ReportId); 81 | } 82 | 83 | if (report == null) 84 | { 85 | result.ErrorMessage = "No report with the given ID was found in the workspace. Make sure ReportId is valid."; 86 | return View(result); 87 | } 88 | 89 | var datasets = await client.Datasets.GetDatasetByIdInGroupAsync(WorkspaceId, report.DatasetId); 90 | result.IsEffectiveIdentityRequired = datasets.IsEffectiveIdentityRequired; 91 | result.IsEffectiveIdentityRolesRequired = datasets.IsEffectiveIdentityRolesRequired; 92 | GenerateTokenRequest generateTokenRequestParameters; 93 | // This is how you create embed token with effective identities 94 | if (!string.IsNullOrWhiteSpace(username)) 95 | { 96 | var rls = new EffectiveIdentity(username, new List { report.DatasetId }); 97 | if (!string.IsNullOrWhiteSpace(roles)) 98 | { 99 | var rolesList = new List(); 100 | rolesList.AddRange(roles.Split(',')); 101 | rls.Roles = rolesList; 102 | } 103 | // Generate Embed Token with effective identities. 104 | generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identities: new List { rls }); 105 | } 106 | else 107 | { 108 | // Generate Embed Token for reports without effective identities. 109 | generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); 110 | } 111 | 112 | var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(WorkspaceId, report.Id, generateTokenRequestParameters); 113 | 114 | if (tokenResponse == null) 115 | { 116 | result.ErrorMessage = "Failed to generate embed token."; 117 | return View(result); 118 | } 119 | 120 | // Generate Embed Configuration. 121 | result.EmbedToken = tokenResponse; 122 | result.EmbedUrl = report.EmbedUrl; 123 | result.Id = report.Id; 124 | 125 | return View(result); 126 | } 127 | } 128 | catch (HttpOperationException exc) 129 | { 130 | result.ErrorMessage = string.Format("Status: {0} ({1})\r\nResponse: {2}\r\nRequestId: {3}", exc.Response.StatusCode, (int)exc.Response.StatusCode, exc.Response.Content, exc.Response.Headers["RequestId"].FirstOrDefault()); 131 | } 132 | catch (Exception exc) 133 | { 134 | result.ErrorMessage = exc.ToString(); 135 | } 136 | 137 | return View(result); 138 | } 139 | 140 | public async Task EmbedDashboard() 141 | { 142 | var error = GetWebConfigErrors(); 143 | if (error != null) 144 | { 145 | return View(new EmbedConfig() 146 | { 147 | ErrorMessage = error 148 | }); 149 | } 150 | 151 | // Create a user password cradentials. 152 | var credential = new UserPasswordCredential(Username, Password); 153 | 154 | // Authenticate using created credentials 155 | var authenticationContext = new AuthenticationContext(AuthorityUrl); 156 | var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential); 157 | 158 | if (authenticationResult == null) 159 | { 160 | return View(new EmbedConfig() 161 | { 162 | ErrorMessage = "Authentication Failed." 163 | }); 164 | } 165 | 166 | var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer"); 167 | 168 | // Create a Power BI Client object. It will be used to call Power BI APIs. 169 | using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) 170 | { 171 | // Get a list of dashboards. 172 | var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(WorkspaceId); 173 | 174 | // Get the first report in the workspace. 175 | var dashboard = dashboards.Value.FirstOrDefault(); 176 | 177 | if (dashboard == null) 178 | { 179 | return View(new EmbedConfig() 180 | { 181 | ErrorMessage = "Workspace has no dashboards." 182 | }); 183 | } 184 | 185 | // Generate Embed Token. 186 | var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); 187 | var tokenResponse = await client.Dashboards.GenerateTokenInGroupAsync(WorkspaceId, dashboard.Id, generateTokenRequestParameters); 188 | 189 | if (tokenResponse == null) 190 | { 191 | return View(new EmbedConfig() 192 | { 193 | ErrorMessage = "Failed to generate embed token." 194 | }); 195 | } 196 | 197 | // Generate Embed Configuration. 198 | var embedConfig = new EmbedConfig() 199 | { 200 | EmbedToken = tokenResponse, 201 | EmbedUrl = dashboard.EmbedUrl, 202 | Id = dashboard.Id 203 | }; 204 | 205 | return View(embedConfig); 206 | } 207 | } 208 | 209 | public async Task EmbedTile() 210 | { 211 | var error = GetWebConfigErrors(); 212 | if (error != null) 213 | { 214 | return View(new TileEmbedConfig() 215 | { 216 | ErrorMessage = error 217 | }); 218 | } 219 | 220 | // Create a user password cradentials. 221 | var credential = new UserPasswordCredential(Username, Password); 222 | 223 | // Authenticate using created credentials 224 | var authenticationContext = new AuthenticationContext(AuthorityUrl); 225 | var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential); 226 | 227 | if (authenticationResult == null) 228 | { 229 | return View(new TileEmbedConfig() 230 | { 231 | ErrorMessage = "Authentication Failed." 232 | }); 233 | } 234 | 235 | var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer"); 236 | 237 | // Create a Power BI Client object. It will be used to call Power BI APIs. 238 | using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) 239 | { 240 | // Get a list of dashboards. 241 | var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(WorkspaceId); 242 | 243 | // Get the first report in the workspace. 244 | var dashboard = dashboards.Value.FirstOrDefault(); 245 | 246 | if (dashboard == null) 247 | { 248 | return View(new TileEmbedConfig() 249 | { 250 | ErrorMessage = "Workspace has no dashboards." 251 | }); 252 | } 253 | 254 | var tiles = await client.Dashboards.GetTilesInGroupAsync(WorkspaceId, dashboard.Id); 255 | 256 | // Get the first tile in the workspace. 257 | var tile = tiles.Value.FirstOrDefault(); 258 | 259 | // Generate Embed Token for a tile. 260 | var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); 261 | var tokenResponse = await client.Tiles.GenerateTokenInGroupAsync(WorkspaceId, dashboard.Id, tile.Id, generateTokenRequestParameters); 262 | 263 | if (tokenResponse == null) 264 | { 265 | return View(new TileEmbedConfig() 266 | { 267 | ErrorMessage = "Failed to generate embed token." 268 | }); 269 | } 270 | 271 | // Generate Embed Configuration. 272 | var embedConfig = new TileEmbedConfig() 273 | { 274 | EmbedToken = tokenResponse, 275 | EmbedUrl = tile.EmbedUrl, 276 | Id = tile.Id, 277 | dashboardId = dashboard.Id 278 | }; 279 | 280 | return View(embedConfig); 281 | } 282 | } 283 | 284 | /// 285 | /// Check if web.config embed parameters have valid values. 286 | /// 287 | /// Null if web.config parameters are valid, otherwise returns specific error string. 288 | private string GetWebConfigErrors() 289 | { 290 | // Application Id must have a value. 291 | if (string.IsNullOrWhiteSpace(ApplicationId)) 292 | { 293 | return "ApplicationId is empty. please register your application as Native app in https://dev.powerbi.com/apps and fill client Id in web.config."; 294 | } 295 | 296 | // Application Id must be a Guid object. 297 | Guid result; 298 | if (!Guid.TryParse(ApplicationId, out result)) 299 | { 300 | return "ApplicationId must be a Guid object. please register your application as Native app in https://dev.powerbi.com/apps and fill application Id in web.config."; 301 | } 302 | 303 | // Workspace Id must have a value. 304 | if (string.IsNullOrWhiteSpace(WorkspaceId)) 305 | { 306 | return "WorkspaceId is empty. Please select a group you own and fill its Id in web.config"; 307 | } 308 | 309 | // Workspace Id must be a Guid object. 310 | if (!Guid.TryParse(WorkspaceId, out result)) 311 | { 312 | return "WorkspaceId must be a Guid object. Please select a workspace you own and fill its Id in web.config"; 313 | } 314 | 315 | // Username must have a value. 316 | if (string.IsNullOrWhiteSpace(Username)) 317 | { 318 | return "Username is empty. Please fill Power BI username in web.config"; 319 | } 320 | 321 | // Password must have a value. 322 | if (string.IsNullOrWhiteSpace(Password)) 323 | { 324 | return "Password is empty. Please fill password of Power BI username in web.config"; 325 | } 326 | 327 | return null; 328 | } 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PowerBIEmbedded_AppOwnsData.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Optimization; 7 | using System.Web.Routing; 8 | 9 | namespace PowerBIEmbedded_AppOwnsData 10 | { 11 | public class MvcApplication : System.Web.HttpApplication 12 | { 13 | protected void Application_Start() 14 | { 15 | AreaRegistration.RegisterAllAreas(); 16 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | BundleConfig.RegisterBundles(BundleTable.Bundles); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Models/EmbedConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.PowerBI.Api.V2.Models; 2 | using System; 3 | 4 | namespace PowerBIEmbedded_AppOwnsData.Models 5 | { 6 | public class EmbedConfig 7 | { 8 | public string Id { get; set; } 9 | 10 | public string EmbedUrl { get; set; } 11 | 12 | public EmbedToken EmbedToken { get; set; } 13 | 14 | public int MinutesToExpiration 15 | { 16 | get 17 | { 18 | var minutesToExpiration = EmbedToken.Expiration.Value - DateTime.UtcNow; 19 | return minutesToExpiration.Minutes; 20 | } 21 | } 22 | 23 | public bool? IsEffectiveIdentityRolesRequired { get; set; } 24 | 25 | public bool? IsEffectiveIdentityRequired { get; set; } 26 | 27 | public bool EnableRLS { get; set; } 28 | 29 | public string Username { get; set; } 30 | 31 | public string Roles { get; set; } 32 | 33 | public string ErrorMessage { get; internal set; } 34 | } 35 | } -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Models/TileEmbedConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.PowerBI.Api.V2.Models; 2 | using System; 3 | 4 | namespace PowerBIEmbedded_AppOwnsData.Models 5 | { 6 | public class TileEmbedConfig : EmbedConfig 7 | { 8 | public string dashboardId { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Project_Readme.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Power BI Embed Samples - App Owns Data 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerBIEmbedded_AppOwnsData")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PowerBIEmbedded_AppOwnsData")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("26b5a5ab-d61b-4db6-9474-ccb43e0312bc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Owin; 2 | using Owin; 3 | 4 | [assembly: OwinStartupAttribute(typeof(PowerBIEmbedded_AppOwnsData.Startup))] 5 | namespace PowerBIEmbedded_AppOwnsData 6 | { 7 | public partial class Startup 8 | { 9 | public void Configuration(IAppBuilder app) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Home/EmbedDashboard.cshtml: -------------------------------------------------------------------------------- 1 | @model PowerBIEmbedded_AppOwnsData.Models.EmbedConfig 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | Layout = "~/Views/Shared/_Layout.cshtml"; 6 | } 7 | 8 | 9 | 10 | 11 | @if (!string.IsNullOrEmpty(Model.ErrorMessage)) 12 | { 13 |
14 |

15 | Error 16 |

17 | @Model.ErrorMessage 18 |
19 | 20 | return; 21 | } 22 | 23 |

Embedded Dashboard

24 |
25 | The following dashboard is the first dashboard found in the given group. Please feel free to change the code to match your needs. 26 |
27 | 28 |
29 | 30 |
31 | Code is in files:
32 | 1) HomeController.cs
33 | 2) EmbedDashboard.cshtml 34 |
35 | 36 | @Html.Partial("LiveDemoLink") 37 | 38 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Home/EmbedReport.cshtml: -------------------------------------------------------------------------------- 1 | @model PowerBIEmbedded_AppOwnsData.Models.EmbedConfig 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | Layout = "~/Views/Shared/_Layout.cshtml"; 6 | } 7 | 8 | 9 | 10 | 11 | @if (!string.IsNullOrEmpty(Model.ErrorMessage)) 12 | { 13 |
14 |

15 | Error 16 |

17 |
 18 |             @Model.ErrorMessage
 19 |         
20 |
21 | 22 | return; 23 | } 24 | 25 |

Embedded Report

26 |
27 | The following report is the first report found in the given group, or the reportId defined in Web.config. Feel free to change the code to match your needs.

28 | @using (Html.BeginForm()) 29 | { 30 |
31 | 32 | 33 |
34 |
35 | This checkbox is disabled because the current report does not support providing effective user name 36 |
37 | For more info, visit RLS link in the bottom of the page 38 |
39 | 50 | } 51 |
52 |
53 | 54 |
55 | Code is in files:
56 | 1) HomeController.cs
57 | 2) EmbedReport.cshtml 58 |
59 | 60 | @Html.Partial("LiveDemoLink") 61 | 62 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Home/EmbedTile.cshtml: -------------------------------------------------------------------------------- 1 | @model PowerBIEmbedded_AppOwnsData.Models.TileEmbedConfig 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | Layout = "~/Views/Shared/_Layout.cshtml"; 6 | } 7 | 8 | 9 | 10 | 11 | @if (!string.IsNullOrEmpty(Model.ErrorMessage)) 12 | { 13 |
14 |

15 | Error 16 |

17 | @Model.ErrorMessage 18 |
19 | 20 | return; 21 | } 22 | 23 |

Embedded Tile

24 |
25 | The following tile is the first tile found in the first dashboard in given group. Please feel free to change the code to match your needs. 26 |
27 |
28 | 29 | @if (string.IsNullOrEmpty(Model.EmbedUrl)) 30 | { 31 | return; 32 | } 33 | 34 |
35 | Code is in files:
36 | 1) HomeController.cs
37 | 2) EmbedTile.cshtml 38 |
39 | 40 | @Html.Partial("LiveDemoLink") 41 | 42 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model PowerBIEmbedded_AppOwnsData.Models.EmbedConfig 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | Layout = "~/Views/Shared/_Layout.cshtml"; 6 | } 7 | 8 |
9 | Select an entity to embed.

10 | 11 | Embed Report 12 |
13 | 14 | Embed Dashboard 15 |
16 | 17 | Embed Tile 18 |
19 | 20 |
21 | Nuget packages which used in this solution
22 | Microsoft.PowerBI.API Version 2.0.3
23 | Microsoft.PowerBI.JavaScript Version 2.3.1
24 |
25 |
-------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Home/LiveDemoLink.cshtml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Error 6 | 7 | 8 |
9 |

Error.

10 |

An error occurred while processing your request.

11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Power BI - Embed Sample 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | @RenderBody() 17 | 18 | 19 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PowerBi-Projects/PowerBI-Developer-Samples/b5fb47bbcbce216726938380a472076c280a3c1d/App Owns Data/PowerBIEmbedded_AppOwnsData/favicon.ico -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PowerBi-Projects/PowerBI-Developer-Samples/b5fb47bbcbce216726938380a472076c280a3c1d/App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PowerBi-Projects/PowerBI-Developer-Samples/b5fb47bbcbce216726938380a472076c280a3c1d/App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PowerBi-Projects/PowerBI-Developer-Samples/b5fb47bbcbce216726938380a472076c280a3c1d/App Owns Data/PowerBIEmbedded_AppOwnsData/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /App Owns Data/PowerBIEmbedded_AppOwnsData/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Install-Package: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PowerBi-Projects/PowerBI-Developer-Samples/b5fb47bbcbce216726938380a472076c280a3c1d/Install-Package -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # App Owns Data samples 2 | 3 | Read this documentation to prepare your environment 4 | https://docs.microsoft.com/en-us/power-bi/developer/embedding-content 5 | 6 | To see embedded report, dashboard and tile, you need to fill missing details in web.config. 7 | 8 | clientId - Id of AAD application registered as NATIVE app. 9 | 10 | groupId - group or workspace Id in Power BI which contains reports, dashboards and tiles you want to embed. 11 | 12 | pbiUsername - Power BI username (e.g. Email). Must be an admin of the group above. 13 | 14 | pbiPassword - password of Power BI user above. 15 | 16 | ### Important 17 | 18 | For security reasons, in real application, don't save the user and password in web.config. Consider using KeyVault 19 | 20 | 21 | # User Owns Data samples 22 | 23 | Please follow these steps to run PowerBI.com Integrate samples: 24 | ## Step 1 - App Registration 25 | You need to register an application in 26 | https://dev.powerbi.com/apps 27 | 28 | ### Registration parameters per sample 29 | 30 | #### integrate-dashboard-web-app 31 | Redirect URL - http://localhost:13526/Redirect 32 | 33 | Home Page URL - http://localhost:13526/ 34 | 35 | #### integrate-report-web-app 36 | Redirect URL - http://localhost:13526/ 37 | 38 | Home Page URL - http://localhost:13526/ 39 | 40 | #### integrate-tile-web-app 41 | Redirect URL - http://localhost:13526/ 42 | 43 | Home Page URL - http://localhost:13526/ 44 | 45 | Registration Example: 46 | 47 | ![regexample](https://cloud.githubusercontent.com/assets/23071967/23340723/fc032efe-fc43-11e6-9a8f-13e40cb32d97.png) 48 | 49 | ## Step 2 - Change Cloud.config 50 | Copy Client Id and Client secret to web.config file 51 | 52 | ![regexample](https://cloud.githubusercontent.com/assets/23071967/23340740/48d4f640-fc44-11e6-8f31-dd273d26a61e.png) 53 | 54 | ## Troubleshooting 55 | 56 | ### Visual Studio 2013 57 | To resolve a 'CS0012:Predefined type 'System.Object' is not defined or imported' error, please update web.config. 58 | 59 | Find line: 60 | ```xml 61 | 62 | ``` 63 | 64 | And modify it to: 65 | 66 | ```xml 67 | 68 | 69 | 70 | 71 | 72 | ``` 73 | 74 | ## Issues 75 | [Power BI Support Page](https://powerbi.microsoft.com/en-us/support/) 76 | 77 | [Power BI Ideas](https://ideas.powerbi.com) 78 | -------------------------------------------------------------------------------- /User Owns Data/CloudConfigs/Power BI Global/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.windows.net/common/oauth2/authorize/ 11 | 12 | 13 | https://analysis.windows.net/powerbi/api 14 | 15 | 16 | https://api.powerbi.com/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/CloudConfigs/Power BI US Government/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.microsoftonline.com/common/oauth2/authorize/ 11 | 12 | 13 | https://analysis.usgovcloudapi.net/powerbi/api 14 | 15 | 16 | https://api.powerbigov.us/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/CloudConfigs/Power BI in Germany/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.microsoftonline.de/common/oauth2/authorize/ 11 | 12 | 13 | https://analysis.cloudapi.de/powerbi/api 14 | 15 | 16 | https://api.powerbi.de/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/CloudConfigs/Power BI operated by 21Vianet in China/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.chinacloudapi.cn/common/oauth2/authorize/ 11 | 12 | 13 | https://analysis.chinacloudapi.cn/powerbi/api 14 | 15 | 16 | https://api.powerbi.cn/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp (Dashboards Sample).sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PBIWebApp", "PBIWebApp\PBIWebApp.csproj", "{633F50D8-EBF6-4921-9D93-46040550305A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.Routing; 5 | using Microsoft.AspNet.FriendlyUrls; 6 | 7 | namespace PBIWebApp 8 | { 9 | public static class RouteConfig 10 | { 11 | public static void RegisterRoutes(RouteCollection routes) 12 | { 13 | var settings = new FriendlyUrlSettings(); 14 | settings.AutoRedirectMode = RedirectMode.Permanent; 15 | routes.EnableFriendlyUrls(settings); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.windows.net/common/oauth2/authorize/ 11 | 12 | 13 | https://login.windows.net/common/oauth2/logout/ 14 | 15 | 16 | https://analysis.windows.net/powerbi/api 17 | 18 | 19 | https://api.powerbi.com/v1.0/myorg/ 20 | 21 | 22 | http://localhost:13526/ 23 | 24 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PBIWebApp._Default" %> 2 | 3 | 4 | 5 |

Power BI: Integrate dashboard sample web applicaton

6 | 7 |

Step 1: Sign in to your Power BI account to link your account to this web application.

8 |

9 | 10 | 11 |

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Signed in as:
Access Token:
29 |
30 |
31 |
32 | 33 |
34 | 35 | 36 |
37 | 38 |
39 |
Step 2: Get dashboards from your account.
40 | 41 |
42 | 43 |
44 | 45 | 46 |
47 |
48 |
49 | 50 |
51 | 52 | 53 |
54 | 55 |
56 |
Step 3: Embed a dashboard
57 | 58 |
Enter an embed url for a dashboard from Step 2 (starts with https://):
59 | 60 |
61 | 62 |
63 | 64 |
65 |
66 |
67 | 68 |
69 | Log View 70 |
71 |
72 |
73 |
74 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Default.aspx.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 7 | using System.Collections.Specialized; 8 | using Newtonsoft.Json; 9 | 10 | namespace PBIWebApp 11 | { 12 | /* NOTE: This sample is to illustrate how to authenticate a Power BI web app. 13 | * In a production application, you should provide appropriate exception handling and refactor authentication settings into 14 | * a configuration. Authentication settings are hard-coded in the sample to make it easier to follow the flow of authentication. */ 15 | public partial class _Default : Page 16 | { 17 | public const string authResultString = "authResult"; 18 | public AuthenticationResult authResult { get; set; } 19 | string baseUri = Properties.Settings.Default.PowerBiDataset; 20 | 21 | protected void Page_Load(object sender, EventArgs e) 22 | { 23 | 24 | //Test for AuthenticationResult 25 | if (Session[authResultString] != null) 26 | { 27 | //Get the authentication result from the session 28 | authResult = (AuthenticationResult)Session[authResultString]; 29 | 30 | //Show Power BI Panel 31 | signInStatus.Visible = true; 32 | signInButton.Visible = false; 33 | signOffButton.Visible = true; 34 | 35 | //Set user and token from authentication result 36 | userLabel.Text = authResult.UserInfo.DisplayableId; 37 | accessTokenTextbox.Text = authResult.AccessToken; 38 | } 39 | else 40 | { 41 | signOffButton.Visible = false; 42 | } 43 | } 44 | 45 | protected void signInButton_Click(object sender, EventArgs e) 46 | { 47 | //Create a query string 48 | //Create a sign-in NameValueCollection for query string 49 | var @params = new NameValueCollection 50 | { 51 | //Azure AD will return an authorization code. 52 | //See the Redirect class to see how "code" is used to AcquireTokenByAuthorizationCode 53 | {"response_type", "code"}, 54 | 55 | //Client ID is used by the application to identify themselves to the users that they are requesting permissions from. 56 | //You get the client id when you register your Azure app. 57 | {"client_id", Properties.Settings.Default.ClientID}, 58 | 59 | //Resource uri to the Power BI resource to be authorized 60 | {"resource", Properties.Settings.Default.PowerBiAPI}, 61 | 62 | //After user authenticates, Azure AD will redirect back to the web app 63 | {"redirect_uri", "http://localhost:13526/Redirect"} 64 | }; 65 | 66 | //Create sign-in query string 67 | var queryString = HttpUtility.ParseQueryString(string.Empty); 68 | queryString.Add(@params); 69 | 70 | //Redirect authority 71 | //Authority Uri is an Azure resource that takes a client id to get an Access token 72 | string authorityUri = Properties.Settings.Default.AADAuthorityUri; 73 | var authUri = String.Format("{0}?{1}", authorityUri, queryString); 74 | Response.Redirect(authUri); 75 | } 76 | 77 | protected void signOffButton_Click(object sender, EventArgs e) 78 | { 79 | //Create a query string 80 | //Create a sign-in NameValueCollection for query string 81 | var @params = new NameValueCollection 82 | { 83 | //Client ID is used by the application to identify themselves to the users that they are requesting permissions from. 84 | //You get the client id when you register your Azure app. 85 | {"client_id", Properties.Settings.Default.ClientID}, 86 | 87 | //Resource uri to the Power BI resource to be authorized 88 | {"resource", Properties.Settings.Default.PowerBiAPI}, 89 | 90 | //After user authenticates, Azure AD will redirect back to the web app 91 | {"redirect_uri", "http://localhost:13526/"}, 92 | 93 | //After user authenticates, Azure AD will redirect back to the web app 94 | {"post_logout_redirect_uri", "http://localhost:13526/Redirect"} 95 | }; 96 | 97 | //Create sign-in query string 98 | var queryString = HttpUtility.ParseQueryString(string.Empty); 99 | queryString.Add(@params); 100 | 101 | //Redirect authority 102 | //Authority Uri is an Azure resource that takes a client id to get an Access token 103 | string authorityUri = Properties.Settings.Default.AADAuthorityUri; 104 | var authUri = String.Format("{0}?{1}", authorityUri, queryString); 105 | Response.Redirect(authUri); 106 | } 107 | 108 | protected void getDashboardsButton_Click(object sender, EventArgs e) 109 | { 110 | string responseContent = string.Empty; 111 | 112 | //Configure dashboards request 113 | System.Net.WebRequest request = System.Net.WebRequest.Create(String.Format("{0}dashboards", baseUri)) as System.Net.HttpWebRequest; 114 | request.Method = "GET"; 115 | request.ContentLength = 0; 116 | request.Headers.Add("Authorization", String.Format("Bearer {0}", authResult.AccessToken)); 117 | 118 | //Get dashboards response from request.GetResponse() 119 | using (var response = request.GetResponse() as System.Net.HttpWebResponse) 120 | { 121 | //Get reader from response stream 122 | using (var reader = new System.IO.StreamReader(response.GetResponseStream())) 123 | { 124 | responseContent = reader.ReadToEnd(); 125 | 126 | //Deserialize JSON string 127 | PBIDashboards PBIDashboards = JsonConvert.DeserializeObject(responseContent); 128 | 129 | if (PBIDashboards != null) 130 | { 131 | var gridViewDashboards = PBIDashboards.value.Select(dashboard => new { 132 | Id = dashboard.id, 133 | DisplayName = dashboard.displayName, 134 | EmbedUrl = dashboard.embedUrl 135 | }); 136 | 137 | this.GridView1.DataSource = gridViewDashboards; 138 | this.GridView1.DataBind(); 139 | } 140 | } 141 | } 142 | } 143 | } 144 | 145 | public class PBIDashboards 146 | { 147 | public PBIDashboard[] value { get; set; } 148 | } 149 | 150 | public class PBIDashboard 151 | { 152 | public string id { get; set; } 153 | public string displayName { get; set; } 154 | public string embedUrl { get; set; } 155 | public bool isReadOnly { get; set; } 156 | } 157 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// SignInPanel control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.Panel SignInPanel; 23 | 24 | /// 25 | /// signInButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button signInButton; 32 | 33 | /// 34 | /// signOffButton control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button signOffButton; 41 | 42 | /// 43 | /// signInStatus control. 44 | /// 45 | /// 46 | /// Auto-generated field. 47 | /// To modify move field declaration from designer file to code-behind file. 48 | /// 49 | protected global::System.Web.UI.WebControls.Panel signInStatus; 50 | 51 | /// 52 | /// userLabel control. 53 | /// 54 | /// 55 | /// Auto-generated field. 56 | /// To modify move field declaration from designer file to code-behind file. 57 | /// 58 | protected global::System.Web.UI.WebControls.Label userLabel; 59 | 60 | /// 61 | /// accessTokenTextbox control. 62 | /// 63 | /// 64 | /// Auto-generated field. 65 | /// To modify move field declaration from designer file to code-behind file. 66 | /// 67 | protected global::System.Web.UI.WebControls.TextBox accessTokenTextbox; 68 | 69 | /// 70 | /// PanelDashboards control. 71 | /// 72 | /// 73 | /// Auto-generated field. 74 | /// To modify move field declaration from designer file to code-behind file. 75 | /// 76 | protected global::System.Web.UI.WebControls.Panel PanelDashboards; 77 | 78 | /// 79 | /// Button1 control. 80 | /// 81 | /// 82 | /// Auto-generated field. 83 | /// To modify move field declaration from designer file to code-behind file. 84 | /// 85 | protected global::System.Web.UI.WebControls.Button Button1; 86 | 87 | /// 88 | /// GridView1 control. 89 | /// 90 | /// 91 | /// Auto-generated field. 92 | /// To modify move field declaration from designer file to code-behind file. 93 | /// 94 | protected global::System.Web.UI.WebControls.GridView GridView1; 95 | 96 | /// 97 | /// PanelEmbed control. 98 | /// 99 | /// 100 | /// Auto-generated field. 101 | /// To modify move field declaration from designer file to code-behind file. 102 | /// 103 | protected global::System.Web.UI.WebControls.Panel PanelEmbed; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PBIWebApp.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Optimization; 6 | using System.Web.Routing; 7 | using System.Web.Security; 8 | using System.Web.SessionState; 9 | 10 | namespace PBIWebApp 11 | { 12 | public class Global : HttpApplication 13 | { 14 | void Application_Start(object sender, EventArgs e) 15 | { 16 | // Code that runs on application startup 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/PBIWebApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {633F50D8-EBF6-4921-9D93-46040550305A} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | PBIWebApp 15 | PBIWebApp 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | true 26 | full 27 | false 28 | bin\ 29 | DEBUG;TRACE 30 | prompt 31 | 4 32 | 33 | 34 | pdbonly 35 | true 36 | bin\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | 43 | 44 | False 45 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll 46 | 47 | 48 | False 49 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | True 70 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 71 | 72 | 73 | ..\packages\Microsoft.AspNet.ScriptManager.MSAjax.5.0.0\lib\net45\Microsoft.ScriptManager.MSAjax.dll 74 | 75 | 76 | ..\packages\Microsoft.AspNet.ScriptManager.WebForms.5.0.0\lib\net45\Microsoft.ScriptManager.WebForms.dll 77 | 78 | 79 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 80 | 81 | 82 | True 83 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 84 | 85 | 86 | True 87 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 88 | 89 | 90 | True 91 | ..\packages\Microsoft.AspNet.Web.Optimization.WebForms.1.1.3\lib\net45\Microsoft.AspNet.Web.Optimization.WebForms.dll 92 | 93 | 94 | ..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.2\lib\net45\Microsoft.AspNet.FriendlyUrls.dll 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | Designer 105 | 106 | 107 | PreserveNewest 108 | Designer 109 | 110 | 111 | 112 | SettingsSingleFileGenerator 113 | Settings.Designer.cs 114 | Designer 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | Designer 123 | 124 | 125 | 126 | Web.config 127 | 128 | 129 | Web.config 130 | 131 | 132 | 133 | 134 | 135 | Default.aspx 136 | ASPXCodeBehind 137 | 138 | 139 | Default.aspx 140 | 141 | 142 | Global.asax 143 | Code 144 | 145 | 146 | 147 | True 148 | True 149 | Settings.settings 150 | 151 | 152 | redirect.aspx 153 | ASPXCodeBehind 154 | 155 | 156 | redirect.aspx 157 | 158 | 159 | Site.Master 160 | ASPXCodeBehind 161 | 162 | 163 | Site.Master 164 | 165 | 166 | 167 | 168 | 10.0 169 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | True 179 | True 180 | 13526 181 | / 182 | http://localhost:13526/ 183 | False 184 | False 185 | 186 | 187 | False 188 | 189 | 190 | 191 | 192 | 199 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PBIWebApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PBIWebApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ef1f4d48-e081-4d2e-8e71-3504d36e6509")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PBIWebApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app ClientID}")] 29 | public string ClientID { 30 | get { 31 | return ((string)(this["ClientID"])); 32 | } 33 | } 34 | 35 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 36 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 37 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app SecretKey}")] 38 | public string ClientSecret { 39 | get { 40 | return ((string)(this["ClientSecret"])); 41 | } 42 | } 43 | 44 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 45 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 46 | [global::System.Configuration.DefaultSettingValueAttribute("https://login.windows.net/common/oauth2/authorize/")] 47 | public string AADAuthorityUri { 48 | get { 49 | return ((string)(this["AADAuthorityUri"])); 50 | } 51 | } 52 | 53 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 55 | [global::System.Configuration.DefaultSettingValueAttribute("https://analysis.windows.net/powerbi/api")] 56 | public string PowerBiAPI { 57 | get { 58 | return ((string)(this["PowerBiAPI"])); 59 | } 60 | } 61 | 62 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("https://api.powerbi.com/v1.0/myorg/")] 65 | public string PowerBiDataset { 66 | get { 67 | return ((string)(this["PowerBiDataset"])); 68 | } 69 | } 70 | 71 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:13526/")] 74 | public string RedirectUrl { 75 | get { 76 | return ((string)(this["RedirectUrl"])); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | {Enter your app ClientID} 7 | 8 | 9 | {Enter your app SecretKey} 10 | 11 | 12 | https://login.windows.net/common/oauth2/authorize/ 13 | 14 | 15 | 16 | https://login.windows.net/common/oauth2/logout/ 17 | 18 | https://analysis.windows.net/powerbi/api 19 | 20 | 21 | https://api.powerbi.com/v1.0/myorg/ 22 | 23 | 24 | http://localhost:13526/ 25 | 26 | 27 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="PBIWebApp.SiteMaster" %> 2 | 3 | 4 | 5 | 6 | 7 | Power BI - Dashboard Embed Sample 8 | 9 | 10 | 11 | 12 | 76 | 77 | 78 |
79 |
80 | 81 | 82 |
83 |
84 | 85 | 86 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Site.Master.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace PBIWebApp 9 | { 10 | public partial class SiteMaster : MasterPage 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Site.Master.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class SiteMaster { 14 | 15 | /// 16 | /// MainContent control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContent; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/css/master.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | 3 | } 4 | 5 | h2 { 6 | font-size: 1.1em; 7 | margin-top: -20px; 8 | font-weight: normal; 9 | } 10 | 11 | h3 { 12 | font-size: 1em; 13 | font-weight: normal; 14 | } 15 | 16 | body { 17 | padding: 10px 50px; 18 | font-family: 'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif; 19 | } 20 | 21 | header { 22 | margin-bottom: 20px; 23 | } 24 | 25 | div { 26 | margin-bottom: 5px; 27 | } 28 | 29 | input[type="submit"], input[type="button"] { 30 | width: 200px; 31 | height: 30px; 32 | background-color: rgb(0, 184, 241); 33 | border: none; 34 | font-weight: bold; 35 | } 36 | 37 | #reportContainer { 38 | background-color: #f5f8fa; 39 | } 40 | 41 | #logView { 42 | background-color: #f5f8fa; 43 | min-height: 100px; 44 | padding: 10px; 45 | } 46 | 47 | .logViewWrap { 48 | margin-top: 20px; 49 | float: none; 50 | width: 100%; 51 | } 52 | 53 | .fieldtxt { 54 | min-width: 150px; 55 | float: left; 56 | } 57 | .step 58 | { 59 | font: 16px arial, verdana; 60 | font-weight: bold; 61 | } 62 | 63 | .grid { 64 | width: 100%; 65 | } 66 | 67 | .gridWrapper { 68 | width: 100%; 69 | height: 250px; 70 | overflow-y: scroll; 71 | background-color: #f5f8fa; 72 | } 73 | 74 | .gridWrapper table { 75 | width: 100% !important; 76 | height: 100%; 77 | border-collapse: collapse; 78 | } 79 | 80 | .gridWrapper td { 81 | border: 1px solid #dddddd; 82 | text-align: left; 83 | padding: 8px; 84 | } 85 | 86 | .gridWrapper th { 87 | border: 1px solid #dddddd; 88 | text-align: left; 89 | padding: 8px; 90 | } 91 | 92 | .gridWrapper tr:nth-child(even) { 93 | background-color: #f5f8fa; 94 | } 95 | 96 | 97 | .gridWrapper tr:nth-child(odd) { 98 | background-color: white; 99 | } 100 | 101 | .embedWrapper { 102 | margin-top: 20px; 103 | } 104 | 105 | #embedInputs { 106 | float: left; 107 | width: 50%; 108 | } 109 | 110 | #embedInputs input[type=text] { 111 | width: 80%; 112 | margin-bottom: 10px; 113 | } 114 | 115 | #embedInputs input[type=button] { 116 | margin-top: 20px; 117 | } 118 | 119 | #dashboardContainer { 120 | width: 90%; 121 | height: 800px; 122 | } 123 | 124 | .stepHr { 125 | margin: 20px 0; 126 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/redirect.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Redirect.aspx.cs" Inherits="PBIWebApp.Redirect" %> 2 | 3 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/redirect.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 8 | using System.Threading.Tasks; 9 | 10 | namespace PBIWebApp 11 | { 12 | /* NOTE: This sample is to illustrate how to authenticate a Power BI web app. 13 | * In a production application, you should provide appropriate exception handling and refactor authentication settings into 14 | * a configuration. Authentication settings are hard-coded in the sample to make it easier to follow the flow of authentication. */ 15 | 16 | public partial class Redirect : System.Web.UI.Page 17 | { 18 | protected void Page_Load(object sender, EventArgs e) 19 | { 20 | //Redirect uri must match the redirect_uri used when requesting Authorization code. 21 | string redirectUri = String.Format("{0}Redirect", Properties.Settings.Default.RedirectUrl); 22 | string authorityUri = Properties.Settings.Default.AADAuthorityUri; 23 | 24 | // Get the auth code 25 | string code = Request.Params["code"]; 26 | 27 | if (code != null) 28 | { 29 | // Get auth token from auth code 30 | TokenCache TC = new TokenCache(); 31 | 32 | AuthenticationContext AC = new AuthenticationContext(authorityUri, TC); 33 | ClientCredential cc = new ClientCredential 34 | (Properties.Settings.Default.ClientID, 35 | Properties.Settings.Default.ClientSecret); 36 | 37 | AuthenticationResult AR = AC.AcquireTokenByAuthorizationCode(code, new Uri(redirectUri), cc); 38 | 39 | //Set Session "authResult" index string to the AuthenticationResult 40 | Session[_Default.authResultString] = AR; 41 | } 42 | else 43 | { 44 | //Remove Session "authResult" 45 | Session[_Default.authResultString] = null; 46 | } 47 | //Redirect back to Default.aspx 48 | Response.Redirect("/Default.aspx"); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/PBIWebApp/redirect.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class Redirect { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /User Owns Data/integrate-dashboard-web-app/README.md: -------------------------------------------------------------------------------- 1 | # Integrate a dashboard into an app 2 | Integrate a Power BI dashboard enables application developers to integrate Power BI dashboards from a user's power BI account by embedding an IFrame into an app, such as a mobile app or web app. 3 | 4 | A documentation for how to run this sample is coming soon. You can follow instructions for report/tile samples for now. To learn how to run this sample, see [Integrate a Power BI tile or report into an app](https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-a-power-bi-tile-or-report/). 5 | 6 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.Routing; 5 | using Microsoft.AspNet.FriendlyUrls; 6 | 7 | namespace PBIWebApp 8 | { 9 | public static class RouteConfig 10 | { 11 | public static void RegisterRoutes(RouteCollection routes) 12 | { 13 | var settings = new FriendlyUrlSettings(); 14 | settings.AutoRedirectMode = RedirectMode.Permanent; 15 | routes.EnableFriendlyUrls(settings); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Cloud.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {Enter your app ApplicationID} 5 | 6 | 7 | https://analysis.windows.net/powerbi/api 8 | 9 | 10 | {Enter your app SecretKey} 11 | 12 | 13 | https://login.windows.net/common/oauth2/authorize/ 14 | 15 | 16 | https://api.powerbi.com/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | 22 | https://api.powerbi.com/ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PBIWebApp._Default" %> 2 | 3 | 4 | 5 | 6 | 7 | 63 | 64 | 65 | 66 |
67 |

68 | Power BI Embed Report 69 |

70 |

71 | Basic Sample 72 |
73 | First make sure you register your app. After registration, copy Application ID and Application Secret to web.config file. 74 |
75 | The application will embed the first report from your Power BI account. If you wish to embed a specific report, please copy the report's ID and the corresponding workspace ID to web.config file. 76 |

77 |
78 | 79 |
80 |

Select "Get Report" to embed the report. 81 |

82 | 83 |
84 | 85 |
86 |
Report Name
87 | 88 |
89 | 90 |
91 |
Report Id
92 | 93 |
94 | 95 |
96 |
Report Embed URL
97 | 98 |
99 |
100 | 101 |
102 |
103 | Embedded Report 104 |
105 |
106 |
107 | 108 |
109 | Log View 110 |
111 |
112 |
113 |
114 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Web; 4 | using System.Web.UI; 5 | using System.Collections.Specialized; 6 | using PBIWebApp.Properties; 7 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 8 | using Microsoft.PowerBI.Api.V2; 9 | using Microsoft.PowerBI.Api.V2.Models; 10 | using Microsoft.Rest; 11 | 12 | namespace PBIWebApp 13 | { 14 | /* NOTE: This code is for sample purposes only. In a production application, you could use a MVC design pattern. 15 | * In addition, you should provide appropriate exception handling and refactor authentication settings into 16 | * a secure configuration. Authentication settings are hard-coded in the sample to make it easier to follow the flow of authentication. 17 | * In addition, the sample uses a single web page so that all code is in one location. However, you could refactor the code into 18 | * your own production model. 19 | */ 20 | public partial class _Default : Page 21 | { 22 | string baseUri = Settings.Default.PowerBiDataset; 23 | 24 | protected void Page_Load(object sender, EventArgs e) 25 | { 26 | 27 | //Need an Authorization Code from Azure AD before you can get an access token to be able to call Power BI operations 28 | //You get the Authorization Code when you click Get Report (see below). 29 | //After you call AcquireAuthorizationCode(), Azure AD redirects back to this page with an Authorization Code. 30 | if (Request.Params.Get("code") != null) 31 | { 32 | //After you get an AccessToken, you can call Power BI API operations such as Get Report 33 | Session["AccessToken"] = GetAccessToken( 34 | Request.Params.GetValues("code")[0], 35 | Settings.Default.ApplicationID, 36 | Settings.Default.ApplicationSecret, 37 | Settings.Default.RedirectUrl); 38 | 39 | //Redirect again to get rid of code= 40 | Response.Redirect("/Default.aspx"); 41 | } 42 | 43 | //After the redirect above to get rid of code=, Session["authResult"] does not equal null, which means you have an 44 | //Access Token. With the Acccess Token, you can call the Power BI Get Reports operation. Get Reports returns information 45 | //about a Report, not the actual Report visual. You get the Report visual later with some JavaScript. See postActionLoadReport() 46 | //in Default.aspx. 47 | if (Session["AccessToken"] != null) 48 | { 49 | //You need the Access Token in an HTML element so that the JavaScript can load a Report visual into an IFrame. 50 | //Without the Access Token, you can not access the Report visual. 51 | accessToken.Value = Session["AccessToken"].ToString(); 52 | 53 | //In this sample, you get the first Report. In a production app, you would create a more robost 54 | //solution 55 | 56 | //Gets the corresponding report to the setting's ReportId and WorkspaceId. 57 | //If ReportId or WorkspaceId are empty, it will get the first user's report. 58 | GetReport(); 59 | } 60 | } 61 | 62 | protected void getReportButton_Click(object sender, EventArgs e) 63 | { 64 | //You need an Authorization Code from Azure AD so that you can get an Access Token 65 | //Values are hard-coded for sample purposes. 66 | GetAuthorizationCode(); 67 | } 68 | 69 | 70 | // Gets a report based on the setting's ReportId and WorkspaceId. 71 | // If reportId or WorkspaceId are empty, it will get the first user's report. 72 | protected void GetReport() 73 | { 74 | var WorkspaceId = Settings.Default.WorkspaceId; 75 | var reportId = Settings.Default.ReportId; 76 | var powerBiApiUrl = Settings.Default.PowerBiApiUrl; 77 | 78 | using (var client = new PowerBIClient(new Uri(powerBiApiUrl), new TokenCredentials(accessToken.Value, "Bearer"))) 79 | { 80 | Report report; 81 | 82 | // Settings' workspace ID is not empty 83 | if (!string.IsNullOrEmpty(WorkspaceId)) 84 | { 85 | // Gets a report from the workspace. 86 | report = GetReportFromWorkspace(client, WorkspaceId, reportId); 87 | } 88 | // Settings' report and workspace Ids are empty, retrieves the user's first report. 89 | else if (string.IsNullOrEmpty(reportId)) 90 | { 91 | report = client.Reports.GetReports().Value.FirstOrDefault(); 92 | AppendErrorIfReportNull(report, "No reports found. Please specify the target report ID and workspace in the applications settings."); 93 | } 94 | // Settings contains report ID. (no workspace ID) 95 | else 96 | { 97 | report = client.Reports.GetReports().Value.FirstOrDefault(r => r.Id == reportId); 98 | AppendErrorIfReportNull(report, string.Format("Report with ID: '{0}' not found. Please check the report ID. For reports within a workspace with a workspace ID, add the workspace ID to the application's settings", reportId)); 99 | } 100 | 101 | if (report != null) 102 | { 103 | txtEmbedUrl.Text = report.EmbedUrl; 104 | txtReportId.Text = report.Id; 105 | txtReportName.Text = report.Name; 106 | } 107 | } 108 | } 109 | 110 | public void GetAuthorizationCode() 111 | { 112 | //NOTE: Values are hard-coded for sample purposes. 113 | //Create a query string 114 | //Create a sign-in NameValueCollection for query string 115 | var @params = new NameValueCollection 116 | { 117 | //Azure AD will return an authorization code. 118 | {"response_type", "code"}, 119 | 120 | //Client ID is used by the application to identify themselves to the users that they are requesting permissions from. 121 | //You get the client id when you register your Azure app. 122 | {"client_id", Settings.Default.ApplicationID}, 123 | 124 | //Resource uri to the Power BI resource to be authorized 125 | //The resource uri is hard-coded for sample purposes 126 | {"resource", Settings.Default.PowerBiAPIResource}, 127 | 128 | //After app authenticates, Azure AD will redirect back to the web app. In this sample, Azure AD redirects back 129 | //to Default page (Default.aspx). 130 | { "redirect_uri", Settings.Default.RedirectUrl} 131 | }; 132 | 133 | //Create sign-in query string 134 | var queryString = HttpUtility.ParseQueryString(string.Empty); 135 | queryString.Add(@params); 136 | 137 | //Redirect to Azure AD Authority 138 | // Authority Uri is an Azure resource that takes a application id and application secret to get an Access token 139 | // QueryString contains 140 | // response_type of "code" 141 | // client_id that identifies your app in Azure AD 142 | // resource which is the Power BI API resource to be authorized 143 | // redirect_uri which is the uri that Azure AD will redirect back to after it authenticates 144 | 145 | //Redirect to Azure AD to get an authorization code 146 | Response.Redirect(String.Format(Settings.Default.AADAuthorityUri + "?{0}", queryString)); 147 | } 148 | 149 | public string GetAccessToken(string authorizationCode, string applicationID, string applicationSecret, string redirectUri) 150 | { 151 | //Redirect uri must match the redirect_uri used when requesting Authorization code. 152 | //Note: If you use a redirect back to Default, as in this sample, you need to add a forward slash 153 | //such as http://localhost:13526/ 154 | 155 | // Get auth token from auth code 156 | TokenCache TC = new TokenCache(); 157 | 158 | //Values are hard-coded for sample purposes 159 | string authority = Settings.Default.AADAuthorityUri; 160 | AuthenticationContext AC = new AuthenticationContext(authority, TC); 161 | ClientCredential cc = new ClientCredential(applicationID, applicationSecret); 162 | 163 | //Set token from authentication result 164 | return AC.AcquireTokenByAuthorizationCode( 165 | authorizationCode, 166 | new Uri(redirectUri), cc).AccessToken; 167 | } 168 | 169 | // Gets the report with the specified ID from the workspace. If report ID is emty it will retrieve the first report from the workspace. 170 | private Report GetReportFromWorkspace(PowerBIClient client, string WorkspaceId, string reportId) 171 | { 172 | // Gets the workspace by WorkspaceId. 173 | var workspaces = client.Groups.GetGroups(); 174 | var sourceWorkspace = workspaces.Value.FirstOrDefault(g => g.Id == WorkspaceId); 175 | 176 | // No workspace with the workspace ID was found. 177 | if (sourceWorkspace == null) 178 | { 179 | errorLabel.Text = string.Format("Workspace with id: '{0}' not found. Please validate the provided workspace ID.", WorkspaceId); 180 | return null; 181 | } 182 | 183 | Report report = null; 184 | if (string.IsNullOrEmpty(reportId)) 185 | { 186 | // Get the first report in the workspace. 187 | report = client.Reports.GetReportsInGroup(sourceWorkspace.Id).Value.FirstOrDefault(); 188 | AppendErrorIfReportNull(report, "Workspace doesn't contain any reports."); 189 | } 190 | 191 | else 192 | { 193 | try 194 | { 195 | // retrieve a report by the workspace ID and report ID. 196 | report = client.Reports.GetReportInGroup(WorkspaceId, reportId); 197 | } 198 | 199 | catch(HttpOperationException) 200 | { 201 | errorLabel.Text = string.Format("Report with ID: '{0}' not found in the workspace with ID: '{1}', Please check the report ID.", reportId, WorkspaceId); 202 | 203 | } 204 | } 205 | 206 | return report; 207 | } 208 | 209 | private void AppendErrorIfReportNull(Report report, string errorMessage) 210 | { 211 | if (report == null) 212 | { 213 | errorLabel.Text = errorMessage; 214 | } 215 | } 216 | } 217 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// accessToken control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.HiddenField accessToken; 23 | 24 | /// 25 | /// getReportButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getReportButton; 32 | 33 | /// 34 | /// txtReportName control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox txtReportName; 41 | 42 | /// 43 | /// txtReportId control. 44 | /// 45 | /// 46 | /// Auto-generated field. 47 | /// To modify move field declaration from designer file to code-behind file. 48 | /// 49 | protected global::System.Web.UI.WebControls.TextBox txtReportId; 50 | 51 | /// 52 | /// txtEmbedUrl control. 53 | /// 54 | /// 55 | /// Auto-generated field. 56 | /// To modify move field declaration from designer file to code-behind file. 57 | /// 58 | protected global::System.Web.UI.WebControls.TextBox txtEmbedUrl; 59 | 60 | /// 61 | /// errorLabel control. 62 | /// 63 | /// 64 | /// Auto-generated field. 65 | /// To modify move field declaration from designer file to code-behind file. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label errorLabel; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PBIWebApp.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Optimization; 6 | using System.Web.Routing; 7 | using System.Web.Security; 8 | using System.Web.SessionState; 9 | 10 | namespace PBIWebApp 11 | { 12 | public class Global : HttpApplication 13 | { 14 | void Application_Start(object sender, EventArgs e) 15 | { 16 | // Code that runs on application startup 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/PBIWebApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {633F50D8-EBF6-4921-9D93-46040550305A} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | PBIWebApp 15 | PBIWebApp 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | true 26 | full 27 | false 28 | bin\ 29 | DEBUG;TRACE 30 | prompt 31 | 4 32 | 33 | 34 | pdbonly 35 | true 36 | bin\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | 43 | 44 | False 45 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.16.204221202\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll 46 | 47 | 48 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.16.204221202\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll 49 | 50 | 51 | ..\packages\Microsoft.PowerBI.Api.2.0.12\lib\portable-net45+win+wpa81+MonoAndroid10+MonoTouch10+xamarinios10+xamarinmac20\Microsoft.PowerBI.Api.dll 52 | True 53 | 54 | 55 | ..\packages\Microsoft.Rest.ClientRuntime.2.0.1\lib\net45\Microsoft.Rest.ClientRuntime.dll 56 | True 57 | 58 | 59 | ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll 60 | True 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | True 83 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 84 | 85 | 86 | ..\packages\Microsoft.AspNet.ScriptManager.MSAjax.5.0.0\lib\net45\Microsoft.ScriptManager.MSAjax.dll 87 | 88 | 89 | ..\packages\Microsoft.AspNet.ScriptManager.WebForms.5.0.0\lib\net45\Microsoft.ScriptManager.WebForms.dll 90 | 91 | 92 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 93 | 94 | 95 | True 96 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 97 | 98 | 99 | True 100 | ..\packages\Microsoft.AspNet.Web.Optimization.WebForms.1.1.3\lib\net45\Microsoft.AspNet.Web.Optimization.WebForms.dll 101 | 102 | 103 | ..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.2\lib\net45\Microsoft.AspNet.FriendlyUrls.dll 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Designer 112 | 113 | 114 | 115 | SettingsSingleFileGenerator 116 | Settings.Designer.cs 117 | Designer 118 | 119 | 120 | 121 | 122 | 123 | 124 | Designer 125 | 126 | 127 | 128 | Web.config 129 | 130 | 131 | Web.config 132 | 133 | 134 | PreserveNewest 135 | Designer 136 | 137 | 138 | 139 | 140 | 141 | Default.aspx 142 | ASPXCodeBehind 143 | 144 | 145 | Default.aspx 146 | 147 | 148 | Global.asax 149 | Code 150 | 151 | 152 | 153 | True 154 | True 155 | Settings.settings 156 | 157 | 158 | Site.Master 159 | ASPXCodeBehind 160 | 161 | 162 | Site.Master 163 | 164 | 165 | 166 | 167 | 10.0 168 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | True 178 | True 179 | 13526 180 | / 181 | http://localhost:13526/ 182 | False 183 | False 184 | 185 | 186 | False 187 | 188 | 189 | 190 | 191 | 198 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PBIWebApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PBIWebApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ef1f4d48-e081-4d2e-8e71-3504d36e6509")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PBIWebApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app ApplicationID}")] 29 | public string ApplicationID { 30 | get { 31 | return ((string)(this["ApplicationID"])); 32 | } 33 | } 34 | 35 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 36 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 37 | [global::System.Configuration.DefaultSettingValueAttribute("https://analysis.windows.net/powerbi/api")] 38 | public string PowerBiAPIResource { 39 | get { 40 | return ((string)(this["PowerBiAPIResource"])); 41 | } 42 | } 43 | 44 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 45 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 46 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app SecretKey}")] 47 | public string ApplicationSecret { 48 | get { 49 | return ((string)(this["ApplicationSecret"])); 50 | } 51 | } 52 | 53 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 55 | [global::System.Configuration.DefaultSettingValueAttribute("https://login.windows.net/common/oauth2/authorize/")] 56 | public string AADAuthorityUri { 57 | get { 58 | return ((string)(this["AADAuthorityUri"])); 59 | } 60 | } 61 | 62 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("https://api.powerbi.com/v1.0/myorg/")] 65 | public string PowerBiDataset { 66 | get { 67 | return ((string)(this["PowerBiDataset"])); 68 | } 69 | } 70 | 71 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:13526/")] 74 | public string RedirectUrl { 75 | get { 76 | return ((string)(this["RedirectUrl"])); 77 | } 78 | } 79 | 80 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 81 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 82 | [global::System.Configuration.DefaultSettingValueAttribute("https://api.powerbi.com/")] 83 | public string PowerBiApiUrl { 84 | get { 85 | return ((string)(this["PowerBiApiUrl"])); 86 | } 87 | } 88 | 89 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 90 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 91 | [global::System.Configuration.DefaultSettingValueAttribute("")] 92 | public string WorkspaceId { 93 | get { 94 | return ((string)(this["WorkspaceId"])); 95 | } 96 | } 97 | 98 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 100 | [global::System.Configuration.DefaultSettingValueAttribute("")] 101 | public string ReportId { 102 | get { 103 | return ((string)(this["ReportId"])); 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | {Enter your app ApplicationID} 7 | 8 | 9 | https://analysis.windows.net/powerbi/api 10 | 11 | 12 | {Enter your app SecretKey} 13 | 14 | 15 | https://login.windows.net/common/oauth2/authorize/ 16 | 17 | 18 | https://api.powerbi.com/v1.0/myorg/ 19 | 20 | 21 | http://localhost:13526/ 22 | 23 | 24 | https://api.powerbi.com/ 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="PBIWebApp.SiteMaster" %> 2 | 3 | 4 | Power BI - Web sample 5 | 6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Site.Master.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace PBIWebApp 9 | { 10 | public partial class SiteMaster : MasterPage 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Site.Master.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class SiteMaster { 14 | 15 | /// 16 | /// Stylesheets control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.ContentPlaceHolder Stylesheets; 23 | 24 | /// 25 | /// MainContent control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContent; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/css/master.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | 3 | } 4 | 5 | h2 { 6 | font-size: 1.1em; 7 | margin-top: -20px; 8 | font-weight: normal; 9 | } 10 | 11 | h3 { 12 | font-size: 1em; 13 | font-weight: normal; 14 | } 15 | 16 | body { 17 | padding: 10px 50px; 18 | font-family: 'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif; 19 | } 20 | 21 | header { 22 | margin-bottom: 20px; 23 | } 24 | 25 | div { 26 | margin-bottom: 5px; 27 | } 28 | 29 | input[type="submit"] { 30 | width: 200px; 31 | height: 30px; 32 | background-color: rgb(0, 184, 241); 33 | border: none; 34 | font-weight: bold; 35 | } 36 | 37 | #reportContainer { 38 | background-color: #f5f8fa; 39 | } 40 | 41 | #logView { 42 | background-color: #f5f8fa; 43 | min-height: 100px; 44 | padding: 10px; 45 | } 46 | 47 | .fieldtxt { 48 | min-width: 150px; 49 | float: left; 50 | } 51 | 52 | .error{ 53 | color: #FF0000; 54 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/PBIWebApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/README.md: -------------------------------------------------------------------------------- 1 | # Source code for integrate a report into an app walkthrough 2 | Integrate a Power BI report enables application developers to integrate Power BI reports from a user's power BI account by embedding an IFrame into an app, such as a mobile app or web app. 3 | 4 | See [Integrate a report into an app walkthrough](https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-report). 5 | -------------------------------------------------------------------------------- /User Owns Data/integrate-report-web-app/pbi-saas-embed-report.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PBIWebApp", "PBIWebApp\PBIWebApp.csproj", "{633F50D8-EBF6-4921-9D93-46040550305A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.Routing; 5 | using Microsoft.AspNet.FriendlyUrls; 6 | 7 | namespace PBIWebApp 8 | { 9 | public static class RouteConfig 10 | { 11 | public static void RegisterRoutes(RouteCollection routes) 12 | { 13 | var settings = new FriendlyUrlSettings(); 14 | settings.AutoRedirectMode = RedirectMode.Permanent; 15 | routes.EnableFriendlyUrls(settings); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Cloud.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {Enter your app ClientID} 5 | 6 | 7 | {Enter your app SecretKey} 8 | 9 | 10 | https://login.windows.net/common/oauth2/authorize/ 11 | 12 | 13 | https://analysis.windows.net/powerbi/api 14 | 15 | 16 | https://api.powerbi.com/v1.0/myorg/ 17 | 18 | 19 | http://localhost:13526/ 20 | 21 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PBIWebApp._Default" %> 2 | 3 | 4 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 |
Tile Embed URL
Dashboard Tile
48 | 49 |
51 |
52 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Default.aspx.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Web; 4 | using System.Web.UI; 5 | using System.Collections.Specialized; 6 | using Newtonsoft.Json; 7 | using PBIWebApp.Properties; 8 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 9 | 10 | namespace PBIWebApp 11 | { 12 | /* NOTE: This code is for sample purposes only. In a production application, you could use a MVC design pattern. 13 | * In addition, you should provide appropriate exception handling and refactor authentication settings into 14 | * a secure configuration. Authentication settings are hard-coded in the sample to make it easier to follow the flow of authentication. 15 | * In addition, the sample uses a single web page so that all code is in one location. However, you could refactor the code into 16 | * your own production model. 17 | */ 18 | public partial class _Default : Page 19 | { 20 | string baseUri = Properties.Settings.Default.PowerBiDataset; 21 | 22 | protected void Page_Load(object sender, EventArgs e) 23 | { 24 | 25 | //Need an Authorization Code from Azure AD before you can get an access token to be able to call Power BI operations 26 | //You get the Authorization Code when you click Get Tile (see below). 27 | //After you call AcquireAuthorizationCode(), Azure AD redirects back to this page with an Authorization Code. 28 | if (Request.Params.Get("code") != null) 29 | { 30 | //After you get an AccessToken, you can call Power BI API operations such as Get Tile 31 | Session["AccessToken"] = GetAccessToken( 32 | Request.Params.GetValues("code")[0], 33 | Settings.Default.ClientID, 34 | Settings.Default.ClientSecret, 35 | Settings.Default.RedirectUrl); 36 | 37 | //Redirect again to get rid of code= 38 | Response.Redirect("/Default.aspx"); 39 | } 40 | 41 | //After the redirect above to get rid of code=, Session["authResult"] does not equal null, which means you have an 42 | //Access Token. With the Acccess Token, you can call the Power BI Get Tiles operation. Get Tiles returns information 43 | //about a tile, not the actual tile visual. You get the tile visual later with some JavaScript. See postActionLoadTile() 44 | //in Default.aspx. 45 | if (Session["AccessToken"] != null) 46 | { 47 | //You need the Access Token in an HTML element so that the JavaScript can load a tile visual into an IFrame. 48 | //Without the Access Token, you can not access the tile visual. 49 | accessToken.Value = Session["AccessToken"].ToString(); 50 | 51 | //Get first dashboard. Sample assumes one dashboard with one tile 52 | string dashboardId = GetDashboard(0); 53 | 54 | //You can get the Dashboard ID with the Get Dashboards operation. Or go to your dashboard, and get it from the url for the dashboard. 55 | //The dashboard id is at the end if the url. For example, https://msit.powerbi.com/groups/me/dashboards/00b7e871-cb98-48ed-bddc-0000c000e000 56 | //In this sample, you get the first tile in the first dashbaord. In a production app, you would create a more robost 57 | //solution 58 | GetTile(dashboardId, 0); 59 | } 60 | } 61 | 62 | protected void getTileButton_Click(object sender, EventArgs e) 63 | { 64 | //You need an Authorization Code from Azure AD so that you can get an Access Token 65 | //Values are hard-coded for sample purposes. 66 | GetAuthorizationCode(); 67 | } 68 | 69 | 70 | //Get a dashbaord id. 71 | protected string GetDashboard(int index) 72 | { 73 | string dashboardId = string.Empty; 74 | 75 | //Configure tiles request 76 | System.Net.WebRequest request = System.Net.WebRequest.Create( 77 | String.Format("{0}Dashboards", 78 | baseUri)) as System.Net.HttpWebRequest; 79 | 80 | request.Method = "GET"; 81 | request.ContentLength = 0; 82 | request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.Value)); 83 | 84 | //Get dashboards response from request.GetResponse() 85 | using (var response = request.GetResponse() as System.Net.HttpWebResponse) 86 | { 87 | //Get reader from response stream 88 | using (var reader = new System.IO.StreamReader(response.GetResponseStream())) 89 | { 90 | //Deserialize JSON string 91 | PBIDashboards dashboards = JsonConvert.DeserializeObject(reader.ReadToEnd()); 92 | 93 | //Sample assumes at least one Dashboard with one Tile. 94 | //You could write an app that lists all tiles in a dashboard 95 | dashboardId = dashboards.value[index].id; 96 | } 97 | } 98 | 99 | return dashboardId; 100 | } 101 | 102 | 103 | //Get a tile from a dashboard. In this sample, you get the first tile. 104 | protected void GetTile(string dashboardId, int index) 105 | { 106 | //Configure tiles request 107 | System.Net.WebRequest request = System.Net.WebRequest.Create( 108 | String.Format("{0}Dashboards/{1}/Tiles", 109 | baseUri, 110 | dashboardId)) as System.Net.HttpWebRequest; 111 | 112 | request.Method = "GET"; 113 | request.ContentLength = 0; 114 | request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.Value)); 115 | 116 | //Get tiles response from request.GetResponse() 117 | using (var response = request.GetResponse() as System.Net.HttpWebResponse) 118 | { 119 | //Get reader from response stream 120 | using (var reader = new System.IO.StreamReader(response.GetResponseStream())) 121 | { 122 | //Deserialize JSON string 123 | PBITiles tiles = JsonConvert.DeserializeObject(reader.ReadToEnd()); 124 | 125 | //Sample assumes at least one Dashboard with one Tile. 126 | //You could write an app that lists all tiles in a dashboard 127 | if (tiles.value.Length > 0) 128 | tileEmbedUrl.Text = tiles.value[index].embedUrl; 129 | } 130 | } 131 | } 132 | 133 | public void GetAuthorizationCode() 134 | { 135 | //NOTE: Values are hard-coded for sample purposes. 136 | //Create a query string 137 | //Create a sign-in NameValueCollection for query string 138 | var @params = new NameValueCollection 139 | { 140 | //Azure AD will return an authorization code. 141 | {"response_type", "code"}, 142 | 143 | //Client ID is used by the application to identify themselves to the users that they are requesting permissions from. 144 | //You get the client id when you register your Azure app. 145 | {"client_id", Settings.Default.ClientID}, 146 | 147 | //Resource uri to the Power BI resource to be authorized 148 | //The resource uri is hard-coded for sample purposes 149 | {"resource", Properties.Settings.Default.PowerBiAPI}, 150 | 151 | //After app authenticates, Azure AD will redirect back to the web app. In this sample, Azure AD redirects back 152 | //to Default page (Default.aspx). 153 | { "redirect_uri", Settings.Default.RedirectUrl} 154 | }; 155 | 156 | //Create sign-in query string 157 | var queryString = HttpUtility.ParseQueryString(string.Empty); 158 | queryString.Add(@params); 159 | 160 | //Redirect to Azure AD Authority 161 | // Authority Uri is an Azure resource that takes a client id and client secret to get an Access token 162 | // QueryString contains 163 | // response_type of "code" 164 | // client_id that identifies your app in Azure AD 165 | // resource which is the Power BI API resource to be authorized 166 | // redirect_uri which is the uri that Azure AD will redirect back to after it authenticates 167 | 168 | //Redirect to Azure AD to get an authorization code 169 | Response.Redirect(String.Format(Properties.Settings.Default.AADAuthorityUri + "?{0}", queryString)); 170 | } 171 | 172 | public string GetAccessToken(string authorizationCode, string clientID, string clientSecret, string redirectUri) 173 | { 174 | //Redirect uri must match the redirect_uri used when requesting Authorization code. 175 | //Note: If you use a redirect back to Default, as in this sample, you need to add a forward slash 176 | //such as http://localhost:13526/ 177 | 178 | // Get auth token from auth code 179 | TokenCache TC = new TokenCache(); 180 | 181 | //Values are hard-coded for sample purposes 182 | string authority = Properties.Settings.Default.AADAuthorityUri; 183 | AuthenticationContext AC = new AuthenticationContext(authority, TC); 184 | ClientCredential cc = new ClientCredential(clientID, clientSecret); 185 | 186 | //Set token from authentication result 187 | return AC.AcquireTokenByAuthorizationCode( 188 | authorizationCode, 189 | new Uri(redirectUri), cc).AccessToken; 190 | } 191 | } 192 | 193 | //Power BI Dashboards used to deserialize the Get Dashboards response. 194 | public class PBIDashboards 195 | { 196 | public PBIDashboard[] value { get; set; } 197 | } 198 | public class PBIDashboard 199 | { 200 | public string id { get; set; } 201 | public string displayName { get; set; } 202 | } 203 | 204 | //Power BI Tiles used to deserialize the Get Tiles response. 205 | public class PBITiles 206 | { 207 | public PBITile[] value { get; set; } 208 | } 209 | public class PBITile 210 | { 211 | public string id { get; set; } 212 | public string title { get; set; } 213 | public string embedUrl { get; set; } 214 | } 215 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------cfe63624-8afe-49b8-9940-15b65992c93d-- 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// accessToken control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.HiddenField accessToken; 23 | 24 | /// 25 | /// getTileButton control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button getTileButton; 32 | 33 | /// 34 | /// tileEmbedUrl control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox tileEmbedUrl; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PBIWebApp.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Optimization; 6 | using System.Web.Routing; 7 | using System.Web.Security; 8 | using System.Web.SessionState; 9 | 10 | namespace PBIWebApp 11 | { 12 | public class Global : HttpApplication 13 | { 14 | void Application_Start(object sender, EventArgs e) 15 | { 16 | // Code that runs on application startup 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/PBIWebApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {633F50D8-EBF6-4921-9D93-46040550305A} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | PBIWebApp 15 | PBIWebApp 16 | v4.5 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | true 26 | full 27 | false 28 | bin\ 29 | DEBUG;TRACE 30 | prompt 31 | 4 32 | 33 | 34 | pdbonly 35 | true 36 | bin\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | 43 | 44 | False 45 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.16.204221202\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll 46 | 47 | 48 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.16.204221202\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | True 69 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 70 | 71 | 72 | ..\packages\Microsoft.AspNet.ScriptManager.MSAjax.5.0.0\lib\net45\Microsoft.ScriptManager.MSAjax.dll 73 | 74 | 75 | ..\packages\Microsoft.AspNet.ScriptManager.WebForms.5.0.0\lib\net45\Microsoft.ScriptManager.WebForms.dll 76 | 77 | 78 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 79 | 80 | 81 | True 82 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 83 | 84 | 85 | True 86 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 87 | 88 | 89 | True 90 | ..\packages\Microsoft.AspNet.Web.Optimization.WebForms.1.1.3\lib\net45\Microsoft.AspNet.Web.Optimization.WebForms.dll 91 | 92 | 93 | ..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.2\lib\net45\Microsoft.AspNet.FriendlyUrls.dll 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Designer 102 | 103 | 104 | PreserveNewest 105 | Designer 106 | 107 | 108 | 109 | SettingsSingleFileGenerator 110 | Settings.Designer.cs 111 | Designer 112 | 113 | 114 | 115 | 116 | Designer 117 | 118 | 119 | Web.config 120 | 121 | 122 | Web.config 123 | 124 | 125 | 126 | 127 | 128 | Default.aspx 129 | ASPXCodeBehind 130 | 131 | 132 | Default.aspx 133 | 134 | 135 | Global.asax 136 | Code 137 | 138 | 139 | 140 | True 141 | True 142 | Settings.settings 143 | 144 | 145 | Site.Master 146 | ASPXCodeBehind 147 | 148 | 149 | Site.Master 150 | 151 | 152 | 153 | 154 | 10.0 155 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | True 165 | True 166 | 13526 167 | / 168 | http://localhost:13526/ 169 | False 170 | False 171 | 172 | 173 | False 174 | 175 | 176 | 177 | 178 | 185 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PBIWebApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PBIWebApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ef1f4d48-e081-4d2e-8e71-3504d36e6509")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PBIWebApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app ClientID}")] 29 | public string ClientID { 30 | get { 31 | return ((string)(this["ClientID"])); 32 | } 33 | } 34 | 35 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 36 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 37 | [global::System.Configuration.DefaultSettingValueAttribute("https://analysis.windows.net/powerbi/api")] 38 | public string PowerBiAPI { 39 | get { 40 | return ((string)(this["PowerBiAPI"])); 41 | } 42 | } 43 | 44 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 45 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 46 | [global::System.Configuration.DefaultSettingValueAttribute("{Enter your app SecretKey}")] 47 | public string ClientSecret { 48 | get { 49 | return ((string)(this["ClientSecret"])); 50 | } 51 | } 52 | 53 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 55 | [global::System.Configuration.DefaultSettingValueAttribute("https://login.windows.net/common/oauth2/authorize/")] 56 | public string AADAuthorityUri { 57 | get { 58 | return ((string)(this["AADAuthorityUri"])); 59 | } 60 | } 61 | 62 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("https://api.powerbi.com/v1.0/myorg/")] 65 | public string PowerBiDataset { 66 | get { 67 | return ((string)(this["PowerBiDataset"])); 68 | } 69 | } 70 | 71 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 73 | [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:13526/")] 74 | public string RedirectUrl { 75 | get { 76 | return ((string)(this["RedirectUrl"])); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | {Enter your app ClientID} 7 | 8 | 9 | https://analysis.windows.net/powerbi/api 10 | 11 | 12 | {Enter your app SecretKey} 13 | 14 | 15 | https://login.windows.net/common/oauth2/authorize/ 16 | 17 | 18 | https://api.powerbi.com/v1.0/myorg/ 19 | 20 | 21 | http://localhost:13526/ 22 | 23 | 24 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="PBIWebApp.SiteMaster" %> 2 | 3 | 4 | Power BI - Web sample 5 | 6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Site.Master.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.UI; 6 | using System.Web.UI.WebControls; 7 | 8 | namespace PBIWebApp 9 | { 10 | public partial class SiteMaster : MasterPage 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Site.Master.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace PBIWebApp { 11 | 12 | 13 | public partial class SiteMaster { 14 | 15 | /// 16 | /// Stylesheets control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.ContentPlaceHolder Stylesheets; 23 | 24 | /// 25 | /// MainContent control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContent; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/css/master.css: -------------------------------------------------------------------------------- 1 | h1 2 | { 3 | font: 18px arial, verdana; 4 | } 5 | p, table 6 | { 7 | font: 14px arial, verdana; 8 | } 9 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/PBIWebApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/README.md: -------------------------------------------------------------------------------- 1 | # Source code for integrate a tile into an app walkthrough 2 | Integrate a Power BI tile enables application developers to integrate Power BI tiles from a user's power BI account by embedding an IFrame into an app, such as a mobile app or web app. 3 | 4 | See [Integrate a tile into an app walkthrough](https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-tile). 5 | -------------------------------------------------------------------------------- /User Owns Data/integrate-tile-web-app/pbi-saas-embed-tile.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PBIWebApp", "PBIWebApp\PBIWebApp.csproj", "{633F50D8-EBF6-4921-9D93-46040550305A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {633F50D8-EBF6-4921-9D93-46040550305A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {633F50D8-EBF6-4921-9D93-46040550305A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | --------------------------------------------------------------------------------