BISharp.PowerBiAuthentication.GetAccessToken C# (CSharp) Method

GetAccessToken() public method

public GetAccessToken ( ) : string
return string
        public string GetAccessToken()
        {
            if (_externalAuth != null)
                return _externalAuth.GetBearerToken();

            return _token.CreateAuthorizationHeader();
        }

Usage Example

        public async Task<ActionResult> Dash(string dashId)
        {
            var pbi = new PowerBiAuthentication(new powerbiWebToken());
            var dashboardClient = new DashboardClient(pbi);
            var dashes = await dashboardClient.List();
            ViewBag.dashes = dashes.value;
            ViewBag.accessToken = pbi.GetAccessToken();

            var firstDash = dashes.value.First(d=>d.id == dashId);
            var tiles = await dashboardClient.Tiles(firstDash.id);

            return View("Index", model: tiles);
        }