cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mak82pk Regular Visitor
Regular Visitor

Alternate to RedirectURL

bi.JPG

Integrate a report into an app for your organization (https://docs.microsoft.com/en-us/power-bi/developer/integrate-report)

 

I am following the above example in my MVC 5 application. I will have reports in different URLs. Therefore, I dont want to generate client id for each report  separately and assigned redirect url to get authentication code.

 

Is there any httpResponse method or way to get the authentication code for example i tried to do something...

 

  var request = (HttpWebRequest)WebRequest.CreateHttp($"{Properties.Settings.Default.AADAuthorityUri}?{queryString}");
            request.Method = "GET";
            var response = (HttpWebResponse)request.GetResponse();
            //... (initialize more fields)

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                string result = sr.ReadToEnd();
                dynamic o = JsonConvert.DeserializeObject(result);
                var token = o.code;
                //   Console.WriteLine("I got Http Status Code: {0}", response.StatusCode);
            }

 so that I can just get the token and pass it to View to display report.

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator Eric_Zhang
Moderator

Re: Alternate to RedirectURL


@mak82pk wrote:

bi.JPG

Integrate a report into an app for your organization (https://docs.microsoft.com/en-us/power-bi/developer/integrate-report)

 

I am following the above example in my MVC 5 application. I will have reports in different URLs. Therefore, I dont want to generate client id for each report  separately and assigned redirect url to get authentication code.


@mak82pk

I think you can use one registered app. Just re-direct to the different embedding pages accordingly.

                //After you get an AccessToken, you can call Power BI API operations such as Get Tile
                Session["AccessToken"] = GetAccessToken(
                    Request.Params.GetValues("code")[0],
                    Settings.Default.ClientID,
                    Settings.Default.ClientSecret,
                    Settings.Default.RedirectUrl);

                //Redirect to the embedding page
                Response.Redirect("/embeding page path");

 

By the way, for any security concern, you'd better mask the user name in the snapshot.

1 REPLY 1
Moderator Eric_Zhang
Moderator

Re: Alternate to RedirectURL


@mak82pk wrote:

bi.JPG

Integrate a report into an app for your organization (https://docs.microsoft.com/en-us/power-bi/developer/integrate-report)

 

I am following the above example in my MVC 5 application. I will have reports in different URLs. Therefore, I dont want to generate client id for each report  separately and assigned redirect url to get authentication code.


@mak82pk

I think you can use one registered app. Just re-direct to the different embedding pages accordingly.

                //After you get an AccessToken, you can call Power BI API operations such as Get Tile
                Session["AccessToken"] = GetAccessToken(
                    Request.Params.GetValues("code")[0],
                    Settings.Default.ClientID,
                    Settings.Default.ClientSecret,
                    Settings.Default.RedirectUrl);

                //Redirect to the embedding page
                Response.Redirect("/embeding page path");

 

By the way, for any security concern, you'd better mask the user name in the snapshot.

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 6 members 1,006 guests
Please welcome our newest community members: