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

Redirect to report server from .NET after api authentication

5 Answers 484 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 16 Jun 2017, 04:05 PM

Hi Guys - I need to be able to log a user straight into the report server after authenticating with the api either in .NET or javascript and retrieving the token via the api (http://localhost:83/Token) instead of showing the login boxes.  

This is a requirement because we use our own authentication mechanism in our web apps and once the user has successfully logged into our app using our authentication methods we do not want them to have to provide any further 'log in details' on the report server - Can you advise how to achieve this.  I think the steps involved may be as follows:

1) user logs into our web app using there own credentials for our business.

2) use the report server API to authenticate and get the token back for an admin account set up by us on report server.

3) after successfully getting the token back, redirect the user to report server from .NET web app using a special account we set up without the requirement for them to log into report server again.

I know there is ADFS available in Telerik report server, however our domain servers are 2003 and do not support the ADFS feature offered by report server - which is why I am looking for an alternative approach.

Hope that makes sense, thanks for your help.:)

 

Anthony J Brown.

5 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 19 Jun 2017, 02:44 PM
Hello Anthony,

You need to authenticate only users who are considered CALs, and who will generate reports or manage resources of the Report Server. all other users can use the guest account to request preview of published reports - Guest user.

In case you need to give access to CALs through the Report Server API, please check: The admin user should create accounts for each CAL before they are able to log on the Report Server.

Regards,
Stef
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
0
Anthony
Top achievements
Rank 1
answered on 19 Jun 2017, 03:00 PM

Hi Stef - I understand that only CAL's users have access however I need to understand how to redirect a user to the report server without being prompted with the credentials screen having already logged in and authenticated via the report server API - for example, I have a CAL user that logs into my app via Active Directory and they already have a non AD/CAL account on the report server from which they are given the bearer token - I don't want them to have to log in twice, once in my app and then again on the report server - is there a way to bypass the login screen once the user has successfully logged in via the API from a .net app and already given the access token?  Can this been achieved using HTTPContext redirect somehow?

I seem to be presented with the report server login screen every time I login via the report server API or javascript and redirect to localhost:83.

Look forward to your help with this one, many thanks

Anthony J Brown

HSS Hire

 

0
Stef
Telerik team
answered on 21 Jun 2017, 04:52 PM
Hello Anthony,

The attached demo project is a WebApplication with Windows Authentication.
In site.Master we add a link that should lead the user to the Admin Module of the Report Server, after login the user through the exposed Report Server's API:
<div class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
        <li><a runat="server" href="~/">Home</a></li>
        <li>
            <a id="btnReportServer">Go to Report Server</a>
        </li>
    </ul>
   
    <script>
        var serverHost = "http://localhost:83/";
        var serverApi = serverHost + "api/reportserver/";
        var serverTokenKey = "TelerikReportServerToken";
 
        function login(username, password) {
 
            var accessToken = "";
 
            $.ajax({
                type: "POST",
                url: serverHost + "Token",
                async: false,
                data: {
                    grant_type: "password",
                    username: username,
                    password: password
                }
            })
            .done(function (data, textStatus, jqXHR) {
                accessToken = data.access_token;
            })
            .fail(function (xhr, status, error) {
                window.alert(xhr.status + ": " + error);
            });
 
            return accessToken;
        }
        $('#btnReportServer').click(function () {
            var accessToken = login("telerik", "telerik123");
            window.sessionStorage.setItem(serverTokenKey, accessToken);
            window.location = serverHost;
        });
    </script>
    <p class="nav navbar-text navbar-right">
        Hello,
        <asp:LoginName runat="server" />
        !
    </p>
</div>



Regards,
Stef
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
0
A
Top achievements
Rank 1
answered on 30 Oct 2018, 06:00 AM

Hi Stef,

I am trying to access with the same way you said in Angular4 project bit showing the below error

status: 400
statusText: "Bad Request"
type: 2
: "http://localhost:83/Token"

error: "unsupported_grant_type"

 

Trying to send the data in below formats

1) Ajax

let = 'http://localhost:83/Token';
let data = {
            grant_type: 'password',
            username: 'manikanta',
            password: 'tj@2018'
        };

var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.send(JSON.stringify(data));
xhr.onloadend = function (e) {
console.log(e);
};

2) Typescript:

let url = 'http://localhost:83/Token';
        let body = JSON.stringify({ 'grant_type': "password", 'username': 'manikanta', 'password': 'tj@2018' });
        return this._http.post(url, body)
            .map((response: Response) => <any>response.json())
            .catch(this.handleError);

 

In both the cases i am geeting same error "unsupported_grant_type"

Please provide the solution for this.

Thanks

 

 

 

0
Todor
Telerik team
answered on 01 Nov 2018, 03:18 PM
Hello Verduzco,

The Stackoverflow threads {“error”:“unsupported_grant_type”} for angular call and {error: “unsupported_grant_type”} angular 5 describe similar issues. Most probably the problem is related to CORS.
You may check the exact requests made by your Angular application with Fiddler - this can give additional information. 
You can also use Postman or Fiddler to make the requests to the Report Server and compare them with the ones made by the Angular application.

Regards,
Todor
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
Anthony
Top achievements
Rank 1
Answers by
Stef
Telerik team
Anthony
Top achievements
Rank 1
A
Top achievements
Rank 1
Todor
Telerik team
Share this question
or