This is a migrated thread and some comments may be shown as answers.

HTML5 Report Viewer - Service URL Attach Cookie

6 Answers 161 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 11 May 2017, 10:57 PM
When using the HTML5 ReportViewer, you can add a service URL for the REST Service.  Is it possible to attach a cookie to the call back to the service?  Our REST Service is in a different App Service so the authentication cookie needs to be passed along.  There is an authentication parameter but doesn't appear to work the way I need it to.

6 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 15 May 2017, 01:41 PM
Hello Joshua,

Please check the following stackoverflow discussion - Why is jquery's .ajax() method not sending my session cookie?. The discussion elaborates why cookies are not sent between different domains and how you can workaround the security settings.

In general, the HTML5 Viewer makes AJAX requests to the Reporting REST Service. We provide mechanism for sending custom header information - authenticationToken attribute of the HTML5 Viewer. You can override the Reporting REST Services methods (ReportsControllerBase methods) to handle the security information by adding attributes and custom code.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Joshua
Top achievements
Rank 1
answered on 15 May 2017, 05:26 PM

Are you are telling me that I can either...

A.  Change my authentication Logic to use this bearer token you speak of instead of using my normal cookie method?

B.  Edit your java script files to implement a hack to the Ajax call that the report viewer makes in the ways described in the link you linked to?

0
Stef
Telerik team
answered on 16 May 2017, 03:15 PM
Hi Joshua,

You can create a token and use it with the HTML% Viewer that makes AJAX requests to the Reporting REST Service (it is a WebAPI controlleR).

You can pass the token through the viewer's authenticationToken, no need to change the viewer's script.

Then you can add authorization attributes on the ReportsControllerBase controller's class and any method in it (methods can be overridden).

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Joshua
Top achievements
Rank 1
answered on 19 May 2017, 01:43 PM

I found I was able to make it work by adding the following code in a common place, 

$.ajaxSetup({ xhrFields: { withCredentials: true}});

This caused ajax to pass the cookie.  Now, the initial call to the reports service works and doesn't give the authorization error, but then it tries to make a second HTTP OPTIONS call to /services/reports/api/reports/clients/094002-f5f9/parameters and it gives a 404 not found error.  Still working on this one.

0
Joshua
Top achievements
Rank 1
answered on 24 May 2017, 11:24 AM
I was able (as mentioned in my other comment) to get the credentials passed through.  Now the first request to service/reports/api/reports/clients works fine and returns a 200 Status Code and returns a client id {in my latest test the client id is 071748-9ec9}.  Then it makes a second request to service/reports/api/reports/clients/071748-9ec9/parameters, it also has created a folder on the server in a temp directory matching the client id.  But this second call to the parameters gets a 404 not found status code.  Any thoughts as to why this would be occurring?
0
Katia
Telerik team
answered on 29 May 2017, 09:00 AM
Hi Joshua,

What is the error message you receive in the viewer?

Check if the viewer's reportSource is configured correctly - How to: Set ReportSource for Report Viewers. Also, check the suggestions listed in this forum post.

Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Joshua
Top achievements
Rank 1
Answers by
Stef
Telerik team
Joshua
Top achievements
Rank 1
Katia
Telerik team
Share this question
or